开发者

Web Service - XML post - Element Order

We built a web service using the REST Starter Kit. It appears that the elements in an X开发者_运维知识库ML post need to be submitted in alphabetical order. What options are there to enable the elements to be any order?


Implement IXmlSerializable on the classes that go over the wire and control the serialization yourself.


Is this REST Starter Kit based on WCF? If so, then you there is an attribute you can use on the class whose instances you want to export, to specify the order of the elements in relation to each other. I think it is the DataMember attribute, one of the options should be for order.

UPDATE: Here is an example:

[DataContract]

public class Person
{
    [DataMember(Order = 2)]
    public Int32 Age { get; set; }

    [DataMember(Order = 0)]
    public String FirstName { get; set; }

    [DataMember(Order = 1)]
    public String LastName { get; set; }
}

Read here for more info - http://dansen.wordpress.com/2008/04/12/controlling-the-serialized-order-of-wcf-data-contract-members/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜