![](/img/trans.png)
[英]Adding User/Password to SOAPHeader for WebService client call with AXIS2
[英]adding SOAPHeader in response in AXIS2 webservice
我想添加肥皂標頭以響應肥皂請求。 我用谷歌搜索了很多。 我發現是添加處理程序並在module.xml中對其進行定義,但是我已將AXIS2 Web服務嵌入到Java Web應用程序中,因此我沒有module.xml或axis2.xml。 在我的項目中,僅在生成axis2服務器端代碼時由axis2 lib自動生成的services.xml。
在WSDL中,操作定義如下:
<operation name="XYZ">
<soap:operation soapAction="SOAP_HTTP#XYZ" />
<input>
<soap:body use="literal" parts="XYZ"
namespace="http://www.ecma-international.org/standards...." />
<soap:header message="wss:header" part="header" use="literal"></soap:header>
</input>
<output>
<soap:body use="literal" parts="XYZResponse"
namespace="http://www.ecma-international.org/standards..." />
<soap:header message="wss:header" part="header" use="literal"></soap:header>
</output>
<fault name="FaultName">
<soap:fault use="literal" name="FaultName"
namespace="http://www.ecma-international.org/standards..." />
</fault>
</operation>
我能夠在請求中成功添加SOAPHeader,還可以從Request和Response兩者中讀取標頭。 但是我無法在SOAP響應中添加SOAPHeader“ header”。
請提供有關如何在SOAP響應中添加soap標頭的建議。
謝謝。
您必須通過Axis2中的新模塊添加處理程序
句柄invoke方法將獲取響應消息上下文,您可以在其中添加標頭。
看到這里: http : //wangxiangblog.blogspot.in/2011/01/develop-web-service-with-axis2-7-add.html
獲取請求標頭
在處理程序中
invoke(MessageContext msgContext) - This is response message context
MessageContext reqMsgCtx = MessageContext.getCurrentMessageContext(); - This gives request message context
//Get header with following code
SOAPEnvelope env = reqMsgCtx.getEnvelope();
SOAPHeader aSoapHeader = env.getHeader();
//將代碼添加到響應消息頭的代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.