How can you force WCF to use xs: All instead of xs: Sequence to make the order of SOAP elements irrelevant?


How can you make WCF use xs:All instead of xs:Sequence when it defines complex object types in the wsdl/xsd for a web service?

The issue I am having is that xs:Sequence requires that calling applications pass the elements in the soap message in the order specified in the WCF generated xsd (this is alphabetical by default). xs:All (or choice for that matter) does not care about the order.

Can this behaviour be changed simply through a configuration option somewhere?

From the top of my head, I think you can't. What you can do instead, is to write the WSDL file by hand, then use svcutil.exe to generate the code.

If all you want to do is order elements in a different order than alphabetically, you can order the elements in the DataContract, using the Order (starting at 1, not 0 like arrays) parameter on the [DataMember] attribute ([DataMember(Order = 1)], [DataMember(Order = 2)], etc).