设置SOAPAction HTTP标头时出现Axis2问题

时间:2009-10-06 12:29:45

标签: web-services axis2

我正在尝试连接到第三方SOAP Web服务。当HTTP SOAPAction 标头是空字符串(“”)时,服务似乎可以工作。这是wsdl的片段:

<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 =“”

我生成了一个stubis 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。

谢谢, RONEN

2 个答案:

答案 0 :(得分: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);

答案 1 :(得分: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版本)。

希望有所帮助。