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

rpe*_*rez 5 axis2 web-services

我正在尝试连接到第三方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>
Run Code Online (Sandbox Code Playgroud)

你在哪里看到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
Run Code Online (Sandbox Code Playgroud)

相反,我得到:

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
Run Code Online (Sandbox Code Playgroud)

有谁知道这是什么问题或如何在程序中设置soapAction.

谢谢,罗恩

Mic*_*rek 2

看看这个问题的答案...您也许能够在生成的存根中找到类似的代码。

如果是这种情况,那么我认为你可以设置操作(根据 API

serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
options.setAction("");
Run Code Online (Sandbox Code Playgroud)

我认为根据 SOAP 版本,该操作的处理方式有所不同。要指定不同的版本:

options.setSoapVersionURI(
    org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
Run Code Online (Sandbox Code Playgroud)

(或常量的 SOAP12 版本)。

希望有帮助。