2009-10-06 69 views
5

我正在嘗試連接到第三方SOAP Web服務。當HTTP SOAPAction標頭爲空字符串(「」)時,似乎該服務可以工作。這是WSDL的片段:設置SOAPAction HTTP標頭時出現Axis2問題

<wsdl:binding name="detailsRequestMessage" type="tns:UssdPortType"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="details"> 
     <soap:operation soapAction=""/> 
     <wsdl:input> 
      <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output> 
      <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 
</wsdl:binding> 

當你看到的soapAction = 「」

我產生stubusing Axis2的(1.5)的WSDL2Java。

希望得到以下(成功輸出與運行了SoapUI時):

POST /details HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: text/xml;charset=UTF-8 
SOAPAction: "" 
User-Agent: Jakarta Commons-HttpClient/3.1 
Host: some.host 
Content-Length: 323 

,而不是我越來越:

POST /details HTTP/1.1 
Content-Type: text/xml; charset=UTF-8 
SOAPAction: "http://some.url/wsussd/ussdtypes/UssdPortType/detailsRequest" 
User-Agent: Axis2 
Host: some.host 
Content-Length: 300 

沒有人有任何想法是什麼問題或如何在程序中設置soapAction。

感謝, 羅南

回答

1

看一看答案this question ...你可以找到類似的代碼在生成的存根。

如果是這樣的話,那麼我認爲你可以設置操作(根據API):

serviceClient = new RPCServiceClient(); 
Options options = serviceClient.getOptions(); 
options.setAction(""); 

我認爲這取決於SOAP版本的動作的處理方式不同。指定不同的版本:

options.setSoapVersionURI(
    org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); 

(或SOAP12版本的常量)。

希望有所幫助。

+0

我試過,沒有運氣。 做的事情是設置選項的屬性。 謝謝 – rperez 2009-10-07 09:54:16

4

rperez對他的回答並不完全清楚。 我發現https://issues.apache.org/jira/browse/AXIS2-4264聲稱這個問題被固定在1.6.0,但我仍然有問題1.6.2

然而,這並不工作:

stub._getServiceClient().getOptions().setProperty(org.apache.axis2.Constants.Configuration.DISABLE_SOAP_ACTION, true);