[英]“SoapException: Server did not recognize the value of HTTP Header SOAPAction” when programmatically defining Binding instead of App.Config
[英]System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction:
当我尝试在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)
Web服务的命名空间:
[WebService(Namespace = "http://internaltest.temp.us/MyWebService.asmx")]
我做了一些研究,发现这个异常流程是因为项目中引用的Web服务的命名空间与服务器Web服务的命名空间不同,但我尝试删除Web引用并在项目中再次添加它,但结果仍然是相同。
我的情况类似于下面的文章:
http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/
来自文章:
所以基本上Web服务从http://foo.com/servicename移到了http://bar.com/servicename,但Web服务的“命名空间”保持为http://foo.com/servicename,因为没有人改变了
问题是:
如何更改Web引用的命名空间?
除了添加或者删除网络的参考,你可以尝试使用再生代理Wsdl.exe用的建议在这里再次,与命名空间。 希望能帮助到你
调用webservice时我也遇到了同样的异常。 在我的客户端代码中,我使用错误的命名空间来引用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");
我不能在不同时使用这两种方法的情况下调用服务。
我希望这将有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.