System.Web.Services.Protocols.SoapException:服务器无法识别HTTP标头SOAPAction的值:
当我尝试在Web服务上调用方法时,会发生exception:
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)
Web服务的命名空间:
[WebService(Namespace = "http://internaltest.temp.us/MyWebService.asmx")]
我做了一些研究,发现这个exception流程是因为项目中引用的Web服务命名空间与服务器Web服务的命名空间不同,但我尝试删除Web引用并在项目中再次添加它,但结果仍然是相同。
我的情况类似于下面的文章:
Server did not recognize the value of HTTP Header SOAPAction
来自文章:
所以基本上Web服务从http://foo.com/servicename转移到http://bar.com/servicename但是Web服务的“命名空间”仍然是http://foo.com/servicename,因为没有人改变了
问题是:
如何更改Web引用的命名空间?
除了删除和添加web-reference之外,您还可以尝试使用wsdl.exe重新生成代理,如此处所示,再次使用命名空间。 希望能帮助到你
调用webservice时我也遇到了同样的exception。 在我的客户端代码中,我使用错误的命名空间来引用WebService。 因此,每当我被引用到WebService时,我都使用完全限定的名称,例如:Namespace.WebService,它为我解决了这个问题。
分享我的经验,因为这可以帮助那里的人。
举例解释案例:
实际方法:
[WebMethod] public string Bar(){ }
您将其重命名为Foo
[WebMethod] public string Foo(){ }
错误地称为方法:
objectName.Bar();
正确的电话:
objectName.Foo();
实际Web方法和被调用方法之间的名称冲突 (因为重命名Web方法)可能导致问题。
获得错误的另一种无耻方式是,如果您正在动态更改端点URL,并且输入了asmx地址而不是wcf地址,反之亦然。
当WS的SOAPAction
属性的值未设置( null
)或在发送的请求中不正确时,可能会发生这种情况。 我正在使用apache库连接到当前项目中的服务,下面你可以找到我的解决方案/解决方法。
import org.apache.axis.client.Call; import org.apache.axis.client.Service; call = (Call) service.createCall(); call = setUseSOAPAction(true);
由于我的apache案例没有setSoapAction
方法,我使用了他们的setProperty
方法并手动将SOAPAction
名称分配给该属性。
call.setProperty("SOAPAction", "expected SOAPAction value"); call.setSOAPActionURI("expected SOAPAction value");
我不能在不同时使用这两种方法的情况下调用服务。
我希望这将有所帮助。
- 使用文本框将数据插入数据库表
- 如何使用“required”htmlattribute向mvc 5 razor视图文本输入编辑器添加自定义错误消息
- 在ASP.NET 2.0中使用Login控件时,将值从一个页面传递到另一个页面
- 跟踪数据库的进度保存在“live”进度条asp.net mvc中
- 如何获取Gridview底层数据源?
- 为什么我没有在Linq Query()中获得.CopyToDataTable()
- 在ASP.NET中是否可以单独从HTTP请求的用户代理字符串派生浏览器MajorVersion?
- asp.net在回发后动态添加用户控件保存值
- 使用Microsoft Jet OLEDB对CSV进行列限制