简体   繁体   English

System.Web.Services.Protocols.SoapException:服务器无法识别HTTP标头SOAPAction的值:

[英]System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction:

An exception flows when I was trying to call a method on web service: 当我尝试在Web服务上调用方法时,会发生异常:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost:53460/3Development/MyWebService.asmx/GetBasePath.
   at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

The web service's namespace: Web服务的命名空间:

[WebService(Namespace = "http://internaltest.temp.us/MyWebService.asmx")]

I did some research and found out that this exception flows because the web service's namespace referenced in the project was different from the server web service's namespace, but I've tried removing web reference and add it again in the project, but the result was still the same. 我做了一些研究,发现这个异常流程是因为项目中引用的Web服务的命名空间与服务器Web服务的命名空间不同,但我尝试删除Web引用并在项目中再次添加它,但结果仍然是相同。

My situation was similar to the below article: 我的情况类似于下面的文章:

http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/ http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/

From Article: 来自文章:

So basically the web service was moved from http://foo.com/servicename to http://bar.com/servicename but the “namespace” of the web service stayed as http://foo.com/servicename because no one changed it. 所以基本上Web服务从http://foo.com/servicename移到了http://bar.com/servicename,但Web服务的“命名空间”保持为http://foo.com/servicename,因为没有人改变了

The problem is: 问题是:

How to change the namespace of the web reference? 如何更改Web引用的命名空间?

In addition to removing and adding web-reference, you could try regenerating proxies using wsdl.exe as suggested here , with the namespace again. 除了添加或者删除网络的参考,你可以尝试使用再生代理Wsdl.exe用的建议在这里再次,与命名空间。 Hope it helps 希望能帮助到你

I also got same exception when calling a webservice. 调用webservice时我也遇到了同样的异常。 In my client code, I was using wrong the Namespace to refer to the WebService. 在我的客户端代码中,我使用错误的命名空间来引用WebService。 So, whenever I was refered to the WebService, I used fully qualified names like: Namespace.WebService, which solved the issue for me. 因此,每当我被引用到WebService时,我都使用了完全限定的名称,例如:Namespace.WebService,它为我解决了这个问题。

Sharing my experience, because this may help someone out there. 分享我的经验,因为这可以帮助那里的人。

Example to explain the case: 举例解释案例:

Actual method: 实际方法:

[WebMethod]
public string Bar(){
}

You renamed it to Foo 您将其重命名为Foo

[WebMethod]
public string Foo(){
}

Wrongly called method: 错误地称为方法:

objectName.Bar();

Correct call: 正确的电话:

objectName.Foo();

A name conflict (because of renaming of web method) between actual web method and the called method can cause the issue. 实际Web方法和被调用方法之间的名称冲突 (因为重命名Web方法)可能会导致问题。

获得错误的另一种无耻方式是,如果您正在动态更改端点URL,并且输入了asmx地址而不是wcf地址,反之亦然。

This can happen when the value of the SOAPAction property of the WS is not set ( null ) or not correct in the request sent. 当WS的SOAPAction属性的值未设置( null )或在发送的请求中不正确时,可能会发生这种情况。 I am using the apache library to connect to the services in my current project, and below you can find my solution/workaround. 我使用apache库连接到当前项目中的服务,下面你可以找到我的解决方案/解决方法。

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

call = (Call) service.createCall();
call = setUseSOAPAction(true);

Since there is not a setSoapAction method for my apache case, I used their setProperty method and assigned the SOAPAction name to that property manually. 由于我的apache情况没有setSoapAction方法,我使用了他们的setProperty方法并手动将SOAPAction名称分配给该属性。

call.setProperty("SOAPAction", "expected SOAPAction value");
call.setSOAPActionURI("expected SOAPAction value");

I could not invoke the service without using those both methods at the same time. 我不能在不同时使用这两种方法的情况下调用服务。

I hope this will help. 我希望这将有所帮助。

暂无
暂无

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

相关问题 通过编程方式定义绑定而不是App.Config时出现“ SoapException:服务器无法识别HTTP标头SOAPAction的值” - “SoapException: Server did not recognize the value of HTTP Header SOAPAction” when programmatically defining Binding instead of App.Config System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.ArgumentNullException - System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException 服务器无法识别 HTTP Header SOAPAction 的值 - Server did not recognize the value of HTTP Header SOAPAction 服务器无法识别HTTP标头SOAPAction的值:“” - Server did not recognize the value of HTTP Header SOAPAction: “” Windows 2008 R2企业版问题(消息:System.Web.Services.Protocols.SoapException:服务器无法处理请求) - Windows 2008 R2 Enterprise Edition Issues(Message:System.Web.Services.Protocols.SoapException: Server was unable to process request) Message =服务器无法识别HTTP标头SOAPAction的值:错误 - Message=Server did not recognize the value of HTTP Header SOAPAction: error 服务器无法识别HTTP标头SOAPAction启动的值 - Server did not recognize the value of HTTP Header SOAPAction initiate System.AggregateException:发生一个或多个错误。 ---> System.Web.Services.Protocols.SoapException - System.AggregateException: One or more errors occurred. ---> System.Web.Services.Protocols.SoapException 有什么方法可以构造System.Web.Services.Protocols.InvokeCompletedEventArgs? - Is there any way to construct System.Web.Services.Protocols.InvokeCompletedEventArgs? System.Web.Services.Protocols.SoapHttpClientProtocol使用什么版本的SSL / TLS? - What version of SSL/TLS does System.Web.Services.Protocols.SoapHttpClientProtocol use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM