Example for adding the SOAP Header element
For adding Version element in the SOAP header. Then final header will look like this.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<SOAP-ENV:Header>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<Version xmlns="http://stack-over-flow.blogcpot.com/schema">1.1</Version>
</SOAP-ENV:Header><SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-615">
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It will add the SOAP header as shown in the example above
When you sent the request at server side if you want to access the header element from the request you can add interceptor like SoapEndpointInterceptor
import java.util.regex.Matcher;
import java.util.regex.Pattern;
private static final Pattern versionNamePattern = Pattern.compile("<Version xmlns=\"
http://stack-over-flow.blogcpot.com/schema\">(.*)</Version>");
String version = (matcher.find())?matcher.group(1):null;
No comments:
Post a Comment