views:

11

answers:

2

We built a web service using the REST Starter Kit. It appears that the elements in an XML post need to be submitted in alphabetical order. What options are there to enable the elements to be any order?

A: 

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

Darrel Miller
A: 

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/

Saajid Ismail