- Add a simple header which contains a String to the request
serviceClient.addStringHeader(new QName("http://wso2.org", "ThirdHeader"), "This is a sample Header");
This is the simplest method of adding a header. But this method restricts you to simple String headers.
- Creating a header as a OMElement and adding it to the request
OMElement firstHeader = AXIOMUtil.stringToOM(
""); This is a sample Header
serviceClient.addHeader(firstHeader);
Users are expected to create the complete header themselves using Axiom's OMElement APIs.
- Creating a header as a SOAPHeaderBlock and adding it to the request
OMNamespace omNamespace =
OMAbstractFactory.getOMFactory().createOMNamespace("http://wso2.com", "ws");
SOAPHeaderBlock secondHeader = OMAbstractFactory.getSOAP12Factory().createSOAPHeaderBlock("SecondHeader", omNamespace);
secondHeader.addChild(AXIOMUtil.stringToOM("This is a sample Header "));
//secondHeader.setMustUnderstand(true);
serviceClient.addHeader(secondHeader);
Users are expected to create the header using Axiom's SOAP APIs. Users could use the API to set various options on the header such as the MustUnderstand Attribute.