Wednesday, April 4, 2012

SOAP message properties are ignored in WCF

Last week, we discovered a strange bug inside WCF.
We have the following datacontract which represents a surface size expressed in Ha, A and Ca:
[DataContract(Namespace = Constants.SCHEMANAME + "Perceel")]
   public class SurfaceSize
       [DataMember(IsRequired = false)]
       public int? Ha { get; set; }
       [DataMember(IsRequired = false)]
       public int? A { get; set; }
       [DataMember(IsRequired = false)]
       public decimal? Ca { get; set; }

We noticed that only the Ha value was saved into the database. We looked at the NHibernate mapping files, the domain mapping code, the queries,… everything looked okay. So we took a look at the only place that was left, the message communication itself.

The following message data was send to us:

We discovered that changing the order of the parameters inside the message solved the problem:


No idea why WCF ignores the parameters when the order has changed. We are not using the Order attribute on our DataContracts.

Anyone who has a clue?


Anonymous said...

Maybe this link is helpful

Bart Wullems said...

Thanks for the link! It gives some extra inside into the problem(unfortunately no solution :-()