Is there a way to make the DataContractSerializer serialize a [MessageContract]
the same way it appears when transmitted over SOAP?
I have a class that appears as follows on the wire for a WCF call:
<TestRequest xmlns="http://webservices.test.com/ServiceTest/1.1">
<Name>Just Me</Name>
</TestRequest>
When serializing using the DCS, it looks like this:
<TestRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" z:Id="1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/ServiceTest">
<_x003C_Name_x003E_k__BackingField z:Id="2">Just Me</_x003C_Name_x003E_k__BackingField>
</TestRequest>
I'm convinced this inconsistency is because my class is marked up as a message contract instead of a data contract:
[MessageContract]
[Serializable]
public class TestRequest
{
[MessageBodyMember]
public string Name { get; set; }
}
Is there a way to make the DCS serialize messages the same way WCF does when it creates a SOAP message?