Here’s my service contract:
[ServiceContract(Namespace = Service.Namespace)]
[XmlSerializerFormat(Style=OperationFormatStyle.Document, Use=OperationFormatUse.Literal)]
public interface IService
{
[OperationContract]
UpdateResponse Update(UpdateRequest request);
}
The implementation:
[ServiceBehavior(Namespace = Namespace)]
public class Service : IService
{
public const string Namespace = "http://schemas.localhost.net/test";
public UpdateResponse Update(UpdateRequest request)
{
return new UpdateResponse() { Succeeded = true };
}
}
The message contracts:
[MessageContract(WrapperNamespace = Service.Namespace)]
public class UpdateRequest
{
[MessageBodyMember]
public int Id { get; set; }
[MessageBodyMember]
public string Name { get; set; }
}
[MessageContract(WrapperNamespace = Service.Namespace)]
public class UpdateResponse
{
[MessageBodyMember]
public bool Succeeded { get; set; }
}
The web.config file (a part of it):
<services>
<service behaviorConfiguration="returnFaults" name="ServiceTest.Service">
<endpoint binding="basicHttpBinding" contract="ServiceTest.IService"
bindingNamespace="http://schemas.localhost.net/test" />
</service>
</services>
And here is the soap message (request) sent from fiddler:
POST http://localhost:10000/Service.svc HTTP/1.1
SOAPAction: "http://schemas.localhost.net/test/IService/Update"
Content-Type: text/xml; charset="utf-8"
Host: localhost:10000
Content-Length: 532
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS1="http://schemas.localhost.net/test">
<NS1:UpdateRequest id="1">
<Name xsi:type="xsd:string">Abcdefg</Name><Id xsi:type="xsd:int">1</Id>
</NS1:UpdateRequest>
<parameters href="#1"/>
</SOAP-ENV:Body>
Update() operation receives an UpdateRequest object, but the fields are not set (Name is null, Id is zero). The response is ok, though.
The Name and Id elements don’t have namespace. So either the soap envelope is not correct, or the MessageContract is not complete. The Name/Id should look like: