views:

118

answers:

2

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?

+2  A: 

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).

Philippe
+1 you nailed in on the head - there's no way out of the box to instruct WCF to use xs:all instead of xs:sequence
marc_s
For once that I have the time to answer a WCF question faster than you do :)
Philippe
Thanks, I thought this may have been the case.
Dean Johnston
A: 

You can switch WCF to use the XmlSerializer instead of DataContractSerializer. The XmlSerializer supports xs:all. See http://msdn.microsoft.com/en-us/library/ms733901.aspx

Eugene Osovetsky