XML Serialization

As you have seen so far, the default option to serialize data types is the data contract serializer, which is implemented via the DataContractSerializer class. However, WCF also supports XmlSerializer. Although XmlSerializer supports fewer types compared to DataContractSerializer, it does provide better control over the resulting XML and also supports more of the XSD standard. Even though DataContractSerializer is the default option, sometimes using XmlSerializer is better:

  • It's better if you are migrating an application from ASP.NET web services to WCF and want to reuse existing types instead of data contracts.

  • It's better when more control over XML is required for it to adhere to some schema.

  • It's better when services need ...

Get Pro WCF: Practical Microsoft SOA Implementation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.