Reputation: 243
I have tried adding the header following the Apache CXF Documentation
List<Header> headers = new ArrayList<Header>();
Header dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), "decapitated",
new JAXBDataBinding(String.class));
headers.add(dummyHeader);
//server side:
context.getMessageContext().put(Header.HEADER_LIST, headers);
//client side:
((BindingProvider)proxy).getRequestContext().put(Header.HEADER_LIST, headers);
This produces header in the format
<SoapHeader>
<dummy xmlns="uri:org.apache.cxf.dummy>decapitated</dummy>
</SoapHeader>
what I want to achieve is
<SoapHeader>
<dummy xmlns="uri:org.apache.cxf.dummy>
<value>decapitated</value>
</dummy>
Upvotes: 2
Views: 2526
Reputation: 7345
One option is to create a SOAPElement and add it to the header, something like this:
SOAPFactory sf = SOAPFactory.newInstance();
SOAPElement seqElement = sf.createElement(new QName("uri:org.apache.cxf","dummy"));
SOAPElement textElement = sf.createElement(new QName("uri:org.apache.cxf","value"));
textElement.addTextNode("decapitated");
seqElement.addChildElement(textElement);
SoapHeader dummyHeader = new SoapHeader(new QName("uri:org.apache.cxf","dummy"), seqElement);
Upvotes: 1