Understanding Data Contracts

Data contracts, in WCF, are the preferred method of abstracting your .NET types from the schema and XML serialized types. With WCF, you have choices for creating the metadata that is used to publish your service and how that impacts the runtime serialization of your .NET types into platform-agnostic schema types that are represented in XML.

The process is all hidden, if you choose, from the developer. Primitive types are easily mapped to leverage the default DataContractSerializer. Other types are controllable through the DataContract attribute capabilities. However, if you still want control, you can always leverage XmlSerializer to manage the serialization of your types into XML. So, in the following sections, ...

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.