Search in sources :

Example 6 with SOAPMessage

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);
    }
}
Also used : MarshallingTypeException(org.openecard.ws.marshal.MarshallingTypeException) WSMarshallerException(org.openecard.ws.marshal.WSMarshallerException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) TransformerException(javax.xml.transform.TransformerException) SAXException(org.xml.sax.SAXException)

Example 7 with SOAPMessage

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;
}
Also used : SOAPMessage(org.openecard.ws.soap.SOAPMessage)

Example 8 with SOAPMessage

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;
}
Also used : Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) SOAPHeader(org.openecard.ws.soap.SOAPHeader)

Aggregations

SOAPMessage (org.openecard.ws.soap.SOAPMessage)8 Document (org.w3c.dom.Document)5 Test (org.testng.annotations.Test)3 Element (org.w3c.dom.Element)3 QName (javax.xml.namespace.QName)2 SOAPBody (org.openecard.ws.soap.SOAPBody)2 SOAPHeader (org.openecard.ws.soap.SOAPHeader)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 StartPAOS (iso.std.iso_iec._24727.tech.schema.StartPAOS)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 TransformerException (javax.xml.transform.TransformerException)1 MarshallingTypeException (org.openecard.ws.marshal.MarshallingTypeException)1 WSMarshaller (org.openecard.ws.marshal.WSMarshaller)1 WSMarshallerException (org.openecard.ws.marshal.WSMarshallerException)1 MessageFactory (org.openecard.ws.soap.MessageFactory)1 SAXException (org.xml.sax.SAXException)1