Deserializing Soap Message

I have a web service with only an Any method where I am receiving a SOAP message marked as [DataContract] with two parameters, both string types and both marked as [DataMember].

Strangely only one parameter gets deserialized properly while the second is null.

There are no exceptions raised and I can currently see the req.GetRawBody() string that is received where both parameters have values.
I can try to deserialize myself the string from the getRawBody but I would like to understand why this is happening.

The orders of the properties is important and can cause this for SOAP/XML, make sure the order of the properties match up with the order they are in the SOAP body. You can use the Order property to assert order, e.g:

public class TestModel
    [DataMember(Order = 1)]
    public int Id { get; set; }

    [DataMember(Order = 2)]
    public string Name { get; set; }
1 Like