Reputation:
I have a .NET 4.0 web service which has an targetNamespace of "http://tempuri.org" when the WSDL is generated. A client is sending me a SOAP envelope with the xmlns set to "uri:company:agent" (see sample below) My service rejects the SOAP envelope since the namespaces are not the same.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:company:agent">
<SOAP-ENV:Body>
<ns1:send_message xmlns="urn:company:agent">
<item1>abc</item1>
I receive the following error:
<faultstring xml:lang="en-US">Error in deserializing body of request message for operation 'send_message'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'send_message' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'ns1:send_message' and namespace 'urn:company:agent'</faultstring>
My Question is as follows: I can't find where to change the namespace of my project within Visual Studio 2010 to reflect "uri:company:agent" instead of "http://tempuri.org/". I've looked extensively but any changes I make do not reflect in the WSDL.
Upvotes: 1
Views: 2613
Reputation: 30006
If you lookt at your .asmx code file it should begin something like this:
[WebService(Namespace = "http://tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class YourServiceName: WebService
{
Just change the tempuri.org url in there. If yours has no Namespace declared there you can declare it, I think tempuri might be the default.
If you're using WCF it will be slightly different. You'll want to look at the top of your .svc file and likely need to add the ServiceBehavior declaration like this:
[ServiceBehavior(Name = "MyService", Namespace = "http://myservice.com/")]
public class Service1 : IService1
{
Upvotes: 1