use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.
the class PAOS method processPAOSRequest.
private Object processPAOSRequest(InputStream content) throws PAOSException {
try {
Document doc = m.str2doc(content);
SOAPMessage msg = m.doc2soap(doc);
// msg.getSOAPHeader().
updateMessageID(msg);
if (LOG.isDebugEnabled()) {
try {
LOG.debug("Message received:\n{}", m.doc2str(doc));
} catch (TransformerException ex) {
LOG.warn("Failed to log PAOS request message.", ex);
}
}
return m.unmarshal(msg.getSOAPBody().getChildElements().get(0));
} catch (MarshallingTypeException ex) {
LOG.error(ex.getMessage(), ex);
throw new PAOSException(ex.getMessage(), ex);
} catch (WSMarshallerException ex) {
String msg = "Failed to read/process message from PAOS server.";
LOG.error(msg, ex);
throw new PAOSException(MARSHALLING_ERROR, ex);
} catch (IOException | SAXException ex) {
String msg = "Failed to read/process message from PAOS server.";
LOG.error(msg, ex);
throw new PAOSException(SOAP_MESSAGE_FAILURE, ex);
}
}
use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.
the class PAOS method createPAOSResponse.
private String createPAOSResponse(Object obj) throws MarshallingTypeException, SOAPException, TransformerException {
SOAPMessage msg = createSOAPMessage(obj);
String result = m.doc2str(msg.getDocument());
LOG.debug("Message sent:\n{}", result);
return result;
}
use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.
the class PAOS method createSOAPMessage.
private SOAPMessage createSOAPMessage(Object content) throws MarshallingTypeException, SOAPException {
Document contentDoc = m.marshal(content);
SOAPMessage msg = m.add2soap(contentDoc);
SOAPHeader header = msg.getSOAPHeader();
// fill header with paos stuff
Element paos = header.addHeaderElement(PAOS_PAOS);
paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "actor", ECardConstants.ACTOR_NEXT);
paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "mustUnderstand", "1");
Element version = header.addChildElement(paos, PAOS_VERSION);
version.setTextContent(ECardConstants.PAOS_VERSION_20);
Element endpointReference = header.addChildElement(paos, PAOS_ENDPOINTREF);
Element address = header.addChildElement(endpointReference, PAOS_ADDRESS);
address.setTextContent("http://www.projectliberty.org/2006/01/role/paos");
Element metaData = header.addChildElement(endpointReference, PAOS_METADATA);
Element serviceType = header.addChildElement(metaData, PAOS_SERVICETYPE);
serviceType.setTextContent(ECardConstants.PAOS_NEXT);
Element replyTo = header.addHeaderElement(REPLY_TO);
address = header.addChildElement(replyTo, ADDRESS);
address.setTextContent("http://www.projectliberty.org/2006/02/role/paos");
// add message IDs
addMessageIDs(msg);
return msg;
}
Aggregations