Search in sources :

Example 1 with SOAPHeader

use of org.openecard.ws.soap.SOAPHeader 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 SOAPHeader

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

the class PAOS method getHeaderElement.

private Element getHeaderElement(SOAPMessage msg, QName elem, boolean create) throws SOAPException {
    Element result = null;
    SOAPHeader h = msg.getSOAPHeader();
    // try to find a header
    for (Element e : h.getChildElements()) {
        if (e.getLocalName().equals(elem.getLocalPart()) && e.getNamespaceURI().equals(elem.getNamespaceURI())) {
            result = e;
            break;
        }
    }
    // if no such element in header, create new
    if (result == null && create) {
        result = h.addHeaderElement(elem);
    }
    return result;
}
Also used : Element(org.w3c.dom.Element) SOAPHeader(org.openecard.ws.soap.SOAPHeader)

Example 3 with SOAPHeader

use of org.openecard.ws.soap.SOAPHeader 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

SOAPHeader (org.openecard.ws.soap.SOAPHeader)3 Element (org.w3c.dom.Element)3 SOAPMessage (org.openecard.ws.soap.SOAPMessage)2 Document (org.w3c.dom.Document)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 StartPAOS (iso.std.iso_iec._24727.tech.schema.StartPAOS)1 BigInteger (java.math.BigInteger)1 QName (javax.xml.namespace.QName)1 WSMarshaller (org.openecard.ws.marshal.WSMarshaller)1 Test (org.testng.annotations.Test)1