简体   繁体   English

SoapAction丢失时,.NET 2.0 Web Service是否可以处理来自客户端的调用?

[英]Can a .NET 2.0 Web Service handle a call from a client when the SoapAction is missing?

We have a .NET 2.0 web service (.ASMX file). 我们有一个.NET 2.0 Web服务(.ASMX文件)。 This web service is being called by a Java client and they are not passing in a SoapAction header. Java客户端正在调用此Web服务,并且它们未传递SoapAction标头。

This causes our web service to fail with the error: : "Server did not recognize the value of HTTP Header SOAPAction: ." 这将导致我们的Web服务失败,并显示以下错误:“服务器无法识别HTTP标头SOAPAction:的值。”

There is no chance that I can convince the development team in charge of the calling Java client to include a SoapAction header. 我完全不可能说服负责调用Java客户端的开发团队包括SoapAction标头。

Is there anyway to resolve this problem on my end? 反正有解决我这个问题的方法吗?

Can I prevent .NET from throwing this error when the SoapAction is missing? 如果缺少SoapAction,是否可以防止.NET引发此错误? Can I direct the call to the correct WebMethod programmatically? 我可以通过编程将调用定向到正确的WebMethod吗?

Something like this psuedo-code, 像这样的伪代码,

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

According to the SOAP 1.1 specification this is required of HTTP clients. 根据SOAP 1.1规范,HTTP客户端需要这样做。

6.1 SOAP HTTP Request 6.1 SOAP HTTP请求

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). 尽管SOAP可以与各种HTTP请求方法结合使用,但是此绑定仅在HTTP POST请求中定义SOAP(有关如何将SOAP用于RPC的信息,请参见第7节;有关如何使用HTTP扩展框架的信息,请参见第6.3节)。

6.1.1 The SOAPAction HTTP Header Field 6.1.1 SOAPAction HTTP标头字段

The SOAPAction HTTP request header field can be used to indicate the intent of the SOAP HTTP request. SOAPAction HTTP请求标头字段可用于指示SOAP HTTP请求的意图。 The value is a URI identifying the intent. 该值是标识意图的URI。 SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. SOAP对URI的格式或特性或可解析的URI不做任何限制。 An HTTP client MUST use this header field when issuing a SOAP HTTP Request. 发出SOAP HTTP请求时,HTTP客户端必须使用此标头字段。

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

From a quick Google it seems this is a common issue with Java and Axis, but there is some debate whether it is required. 从一个快速的Google看来,这似乎是Java和Axis的常见问题,但是是否需要它存在一些争论。 Could this help you convince the Java developers that they need to implement the header? 这可以帮助您说服Java开发人员他们需要实现标头吗?

Edit: 编辑:

The correct URI for your SoapAction http header is defined in the WSDL document. WSDL文档中定义了SoapAction http标头的正确URI。

Goto http://mydomain.com/myservice.asmx?wsdl 转到http://mydomain.com/myservice.asmx?wsdl

Look for the wsdl:operation element for the method you are calling, it should have a child element soap:operation which has a attribute called soapaction, the URI in there is the one you should use. 在要调用的方法中寻找wsdl:operation元素,它应该有一个子元素soap:operation,它具有一个称为soapaction的属性,其中的URI应该是您所使用的。 In a webservice i tested it looks like the namespace followed by / and the method name as follows. 在我测试过的Web服务中,它看起来像是名称空间,后跟/,方法名称如下。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM