cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Cheng <christopher.sw.ch...@gmail.com>
Subject Adding complex XML elements to SOAPHeader
Date Mon, 10 Jul 2017 13:26:42 GMT
I would like to add an XML element like this in SOAP header

<soap:Header>
      <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
         <Property
name="instanceId">f49f1377-453c-44ac-b6fe-541739a6e492</Property>
      </Context>
</soap:Header>


I could not find any example other than adding a simple string to it.
I tried the following, but it doesn't work

Document xmlDoc = new DocumentImpl();
Element root = xmlDoc.createElement("Property");
root.setAttribute("name", "instanceId");
root.setTextContent("f49f1377-453c-44ac-b6fe-541739a6e492");
xmlDoc.appendChild(root);

SoapHeader testSoapHeader1 = new SoapHeader(new
QName("http://schemas.microsoft.com/ws/2006/05/context", "Context"),
xmlDoc, new JAXBDataBinding(com.sun.org.apache.xerces.internal.dom.DocumentImpl.class));
headersList.add(testSoapHeader1);

Client proxy = ClientProxy.getClient(port);
proxy.getRequestContext().put(Header.HEADER_LIST, headersList);

Any idea?

Mime
View raw message