开发者

Web Service - XML post - Element Order

开发者 https://www.devze.com 2023-01-05 21:45 出处:网络
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

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

精彩评论

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