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:
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?
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:
<c:SurfaceSize> <c:Ha>99</e6:Ha> <c:A>9</e6:A> <c:Ca>10</e6:Ca> </c:SurfaceSize>
We discovered that changing the order of the parameters inside the message solved the problem:
<c:SurfaceSize> <c:A>9</c:A> <c:Ca>10</c:Ca> <c:Ha>99</c:Ha> </c:SurfaceSize>
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?