Need practical examples when xmlserializer and message contracts are used by wcf RRS feed

  • Question

  • I know that xmlserializer is used by asmx web services to serialize/deserialze the messages. But i would like to  understand a practical example when xmlserializer is used  by wcf.

    Similarly I would like to understand a practical example when a message contract is used.

    Wednesday, February 13, 2013 5:01 AM


  • In particular, DataContractSerializer does not support attributes like XmlElementAttribute and XmlAttributeAttribute. To enable support for this programming model, WCF must be switched to use the XmlSerializer instead of the DataContractSerializer. For example,

    When your WCF service consumer is expecting an xml response with data as attributes for a single node in below format,

    <Person Name="Lingaraj Mishra" Email="" Phone="111-222-333" /> 

    You can't do this with the DataContractSerializer. DCS will always serialize in this fashion.

        <Name>Lingaraj Mishra</Name>

    If you want attributes you need to use the XmlSerializer instead.

    Lingaraj Mishra

    Wednesday, February 13, 2013 12:25 PM