I have a C # WCF REST service that allows me to add a bookmark by sending an HTTP POST request with entries serialized in XML. I have specified an operation contract for a service that picks up xml and automatically deserializes the object for me. My problem is that deserialization works correctly if the XML elements in the request are listed in alphabetical order and the values ββfor any elements that are out of order are not populated.
This was reported elsewhere .
I find this rather unsatisfactory; I find it necessary to build XML in a certain order to be unnecessary, and a serious headache. This is a basic requirement to add services to all clients and is a source of potentially complex debugging issues.
Is it possible to associate WCF with an attribute of an agnostic XML element?
Additional information for clarification:
My job contract is as follows:
[OperationContract] [WebInvoke(Method="POST", UriTemplate = "/{username}/bookmarks", ResponseFormat = WebMessageFormat.Xml)] public void PostBookmark(string username, RestBookmark newBookmark);
RestMessage is as follows:
[DataContract(Name = "Bookmark", Namespace = "")] public class RestBookmark { [DataMember] public string BookmarkMd5 { get; set; } [DataMember] public string Url { get; set; } [DataMember] public string UserName { get; set; } [DataMember] public string Title { get; set; } [DataMember] public string Description { get; set; } }
If I send the following XML message, when I call PostBookmark (), only the UserName property of the RestMessage object will be populated:
<?xml version="1.0"?><Bookmark><UserName>nick.street</UserName><Url>http://www.stackoverflow.com</Url><BookmarkMd5>f184eb3347cf94f6ce5f5fc2844e3bdd</BookmarkMd5><Description>Developer Forum</Description><Title>Stack Overflow</Title></Bookmark>
c # rest wcf
Nick street
source share