Let’s say you have a WCF web service with RESTful bindings that accepts complex objects and you’re having trouble figuring out why some of your properties and fields on the complex objects never seem to serialize properly. Maybe you’ve even popped open Wireshark and you know that the data is being put on the wire but for whatever reason, some of it never shows up on the server. It’s apparently random and not related to the data type of the field being serialized.
Well, my little frustrated hacker, try putting the fields in your complex object on the client side in alphabetical order and see if that doesn’t just cheer you right up. You see, the DataContractSerializer which is the serialization object for WCF serializes the data in alphabetical order. That’s just how it rolls. And part of how it rolls is dictating to the client what order their XML has to be in.
I’m sure there’s a reason for it. And I’d love to know what it is. Since I just spent 12 hours figuring it out. Part of me thinks it’s Microsoft giving REST the bird but never attribute to malice what can be explained by ignorance and all that. Meh.