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);
}
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;
}
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;
}
Aggregations