none
WCF XSD sequence issue RRS feed

  • Question

  • I have a WCF service built using .NET 4.0 hosted in IIS 7. The generated XSD shows an <sequence> element for the input parameter. This forces the Client to send the inputs in a sequence. How do I change the <sequence> to <all> which doesn't force the inputs to be in a sequence.

    Please help. Thanks.


    Wednesday, April 30, 2014 6:19 PM

All replies

  • Hi,

    Maybe you can switch WCF to use the XmlSerializer instead of DataContractSerializer. The XmlSerializer supports xs:all. For more information, please try to refer to:
    #Using the XmlSerializer:
    http://msdn.microsoft.com/en-us/library/ms733901.aspx .

    Also you could write your own extension to create the WSDL if you really want to - it's not totally trivial, but it can be done, 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).

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 1, 2014 7:23 AM
    Moderator
  • Thanks, Amy.  Do you have any sample code for the XmlSerializer that serializes a class. 


    Friday, May 2, 2014 9:54 PM
  • Do you have any sample code for the XmlSerializer that serializes a class. 


    Hi,

    Please try to check the following articles:
    #Simple XmlSerializer example:
    http://www.jonasjohn.de/snippets/csharp/xmlserializer-example.htm .
    #XmlSerializer in C#:
    http://www.c-sharpcorner.com/Blogs/5036/xmlserializer-in-C-Sharp.aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 8, 2014 7:58 AM
    Moderator