Reputation: 4919
An exception flows when I was trying to call a method on web service:
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:
[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.
My situation was similar to the below article:
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.
The problem is:
How to change the namespace of the web reference?
Upvotes: 9
Views: 37873
Reputation: 807
This can happen when the value of the SOAPAction
property of the WS is not set (null
) or not correct in the request sent. I am using the apache library to connect to the services in my current project, and below you can find my solution/workaround.
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.
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.
Upvotes: 0
Reputation: 31335
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
[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.
Upvotes: 1
Reputation: 709
Another shameless way to get the error is that if you are dynamically changing the endpoint url and you put in an asmx address instead of a wcf one and vice versa.
Upvotes: 0
Reputation: 41
I also got same exception when calling a webservice. In my client code, I was using wrong the Namespace to refer to the WebService. So, whenever I was refered to the WebService, I used fully qualified names like: Namespace.WebService, which solved the issue for me.
Upvotes: 2
Reputation: 1188
In addition to removing and adding web-reference, you could try regenerating proxies using wsdl.exe as suggested here, with the namespace again. Hope it helps
Upvotes: 7