Search in sources :

Example 1 with SOAPMessage

use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.

the class AndroidMarshallerTest method testSOAP.

@Test
public void testSOAP() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    StartPAOS sp = new StartPAOS();
    sp.setSessionIdentifier("5ec5ebb1dd254f392e6ca33cf5bf");
    ConnectionHandleType connectionHandleType = new ConnectionHandleType();
    connectionHandleType.setContextHandle(new BigInteger("94D7439CE657561E7AE3D491FD71AC21F8BCBB5608BA61F5A0EA52269BC01250", 16).toByteArray());
    connectionHandleType.setSlotHandle(new BigInteger("EEB49368C1152BEC379DA59356D59039CA7757AC3EAF9430285F2CBB3DD6EDDD", 16).toByteArray());
    sp.getConnectionHandle().add(connectionHandleType);
    Document contentDoc = m.marshal(sp);
    SOAPMessage msg = m.add2soap(contentDoc);
    SOAPHeader header = msg.getSOAPHeader();
    // fill header with paos stuff
    Element paos = header.addHeaderElement(new QName(ECardConstants.PAOS_VERSION_20, "PAOS"));
    paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "actor", ECardConstants.ACTOR_NEXT);
    paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "mustUnderstand", "1");
    Element version = header.addChildElement(paos, new QName(ECardConstants.PAOS_VERSION_20, "Version"));
    version.setTextContent(ECardConstants.PAOS_VERSION_20);
    Element endpointReference = header.addChildElement(paos, new QName(ECardConstants.PAOS_VERSION_20, "EndpointReference"));
    Element address = header.addChildElement(endpointReference, new QName(ECardConstants.PAOS_VERSION_20, "Address"));
    address.setTextContent("http://www.projectliberty.org/2006/01/role/paos");
    Element metaData = header.addChildElement(endpointReference, new QName(ECardConstants.PAOS_VERSION_20, "MetaData"));
    Element serviceType = header.addChildElement(metaData, new QName(ECardConstants.PAOS_VERSION_20, "ServiceType"));
    serviceType.setTextContent("http://www.bsi.bund.de/ecard/api/1.0/PAOS/GetNextCommand");
    // add message ids
    SOAPHeader h = msg.getSOAPHeader();
    Element elem = h.addHeaderElement(new QName(ECardConstants.WS_ADDRESSING, "RelatesTo"));
    elem.setTextContent("relatesto");
    elem = h.addHeaderElement(new QName(ECardConstants.WS_ADDRESSING, "MessageID"));
    elem.setTextContent("messageid");
    String responseStr = m.doc2str(msg.getDocument());
    LOG.debug(responseStr);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) StartPAOS(iso.std.iso_iec._24727.tech.schema.StartPAOS) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) BigInteger(java.math.BigInteger) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) SOAPHeader(org.openecard.ws.soap.SOAPHeader) Test(org.testng.annotations.Test)

Example 2 with SOAPMessage

use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.

the class JAXBMarshaller method add2soap.

@Override
public synchronized SOAPMessage add2soap(Document content) throws SOAPException {
    SOAPMessage msg = soapFactory.createMessage();
    SOAPBody body = msg.getSOAPBody();
    body.addDocument(content);
    return msg;
}
Also used : SOAPBody(org.openecard.ws.soap.SOAPBody) SOAPMessage(org.openecard.ws.soap.SOAPMessage)

Example 3 with SOAPMessage

use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.

the class MarshalTest method testSoapHeaderAdd.

@Test
public void testSoapHeaderAdd() throws Exception {
    JAXBMarshaller m = new JAXBMarshaller();
    Document doc = m.str2doc(xmlStr);
    SOAPMessage msg = m.doc2soap(doc);
    Element msgId = null;
    // check if messageid is present
    for (Element next : msg.getSOAPHeader().getChildElements()) {
        if (next.getNodeName().equals("MessageID") && next.getNamespaceURI().equals("http://www.w3.org/2005/03/addressing")) {
            msgId = next;
        }
    }
    assertNotNull(msgId);
    // add relates to
    Element relates = msg.getSOAPHeader().addHeaderElement(new QName("http://www.w3.org/2005/03/addressing", "RelatesTo"));
    relates.setTextContent("relates to fancy id");
    System.out.println(m.doc2str(msg.getDocument()));
}
Also used : QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) Test(org.testng.annotations.Test)

Example 4 with SOAPMessage

use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.

the class MarshalTest method testSOAPMarshal.

@Test
public void testSOAPMarshal() throws Exception {
    JAXBMarshaller m = new JAXBMarshaller();
    Document doc = m.str2doc(xmlStr);
    SOAPMessage msg = m.doc2soap(doc);
    Object o = m.unmarshal(msg.getSOAPBody().getChildElements().get(0));
    doc = m.marshal(o);
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage soapMsg = factory.createMessage();
    soapMsg.getSOAPBody().addDocument(doc);
// soapMsg.writeTo(System.out);
}
Also used : MessageFactory(org.openecard.ws.soap.MessageFactory) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) Test(org.testng.annotations.Test)

Example 5 with SOAPMessage

use of org.openecard.ws.soap.SOAPMessage in project open-ecard by ecsec.

the class AndroidMarshaller method add2soap.

@Override
public SOAPMessage add2soap(Document content) throws SOAPException {
    SOAPMessage msg = soapFactory.createMessage();
    SOAPBody body = msg.getSOAPBody();
    body.addDocument(content);
    return msg;
}
Also used : SOAPBody(org.openecard.ws.soap.SOAPBody) SOAPMessage(org.openecard.ws.soap.SOAPMessage)

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