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