java - adding SOAPHeader in response in AXIS2 webservice -
I want to add soap headers in response to a soap request. I have done a lot. What I have found is to add headlines and define it in module.xml, but I have embedded the Axis 2 web service in Java web application so I have the module XML or Axis 2.xml is not My project only has services.xml which is autosenerated by axis2 lib, while the axis2 server generates side code.
In WSDL, the operation is defined as below:
& Lt; Input & gt; & Lt; Soap: body usage = "literal" parts = "XYZ" name space = "http: //www.ecma-international.org/standards ...." /> & Lt; Soap: header message = "wss: header" part = "header" usage = "literal" & gt; & Lt; / Soap: Header & gt; & Lt; / Input & gt; & Lt; Production & gt; & Lt; Soap: body use = "literal" parts = "XYZResponse" namespace = "http: //www.ecma-international.org/standards ..." /> & Lt; Soap: header message = "wss: header" part = "header" usage = "literal" & gt; & Lt; / Soap: Header & gt; & Lt; / Product & gt; & Lt; Mistake name = "FaultName" & gt; & Lt; Soap: defect usage = "literal" name = "FaultName" namespace = "http: //www.ecma-international.org/standards ..." /> & Lt; / Fault & gt; & Lt; / Operation & gt;
I successfully add the SOAPHeader to the request and read the header from both the request and the reply. But I am not able to add SOAPHeader "Header" in SOAP response.
Please provide your suggestions on how to add soap headers to SOAP feedback
thanks.
You have to add a handler to a new module in Axis 2
handle The invoice method will get a response message reference and you can add headers there.
See here:
To get a request header
in handler
invoke (MessageContext msgContext) - this response Message reference messageContact reqMsgCtx = MessageContext.getCurrentMessageContext (); - Get the header with this request message reference / following code SOAPEnvelope env = reqMsgCtx.getEnvelope (); SOAPHeader aSoapHeader = env.getHeader ();
// Your code for adding header blocks for response message header
Comments
Post a Comment