有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java可以是一个很好的工具。NET 2.0 Web服务是否在缺少SoapAction时处理来自客户端的调用?

我们有一个好主意。NET 2.0 web服务(.ASMX文件)。Java客户机正在调用此web服务,它们没有传入SoapAction头

这导致我们的web服务失败,错误为:“服务器未识别HTTP标头SOAPAction:的值。”

我不可能说服负责调用Java客户机的开发团队包含SoapAction头

我这边有没有办法解决这个问题

我能阻止吗。NET在SoapAction丢失时抛出此错误?我可以通过编程方式将调用定向到正确的WebMethod吗

类似于这个psuedo代码

if (Header.SoapAction == String.Empty) then MyWebMethod();

共 (1) 个答案

  1. # 1 楼答案

    根据SOAP1.1规范,这是HTTP客户端所必需的

    6.1 SOAP HTTP Request

    Although SOAP might be used in combination with a variety of HTTP request methods, this binding only defines SOAP within HTTP POST requests (see section 7 for how to use SOAP for RPC and section 6.3 for how to use the HTTP Extension Framework).

    6.1.1 The SOAPAction HTTP Header Field

    The SOAPAction HTTP request header field can be used to indicate the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. An HTTP client MUST use this header field when issuing a SOAP HTTP Request.

    资料来源http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528

    从快速的谷歌上看,这似乎是Java和Axis的一个常见问题,但是否需要它还有一些争论。这能帮助您说服Java开发人员他们需要实现头部吗

    编辑:

    您的SoapActionhttp头的正确URI在WSDL文档中定义

    后藤http://mydomain.com/myservice.asmx?wsdl

    查找您正在调用的方法的wsdl:operation元素,它应该有一个子元素soap:operation,它有一个名为soapaction的属性,其中的URI是您应该使用的URI。在我测试的一个Web服务中,它看起来像是命名空间后跟/和方法名,如下所示

    <wsdl:operation name="AddTwoNumbers">
      <soap:operation soapAction="http://mydomain.com/myservice/AddTwoNumbers" style="document"/>