SoapCore
SoapCore copied to clipboard
Getting null values when using DataMember Name on public properties
I need to integrate against an established schema which has some obscure field names. Currently I can only get this to work when the Data Members exactly match the values in the SOAP message. For example:
<exchange>
<supId>Supplier 123</supId>
<ntlId>National 123</ntlId>
</exchange>
[DataContract]
public class Exchange
{
[DataMember]
public string supId { get; set; }
[DataMember]
public string ntlId { get; set; }
}
If I try to improve the model by giving more meaningful names to the properties and setting their associated name in the data member, this has no effect and the method call results in null values for the supplierId and nationalId properties.
[DataContract]
public class Exchange
{
[DataMember(Name="supId")]
public string supplierId { get; set; }
[DataMember(Name="ntlId")]
public string nationalId { get; set; }
}
Should this be possible, or must the names exactly match the values in the SOAP message?