Introducing Data Contracts

Data contracts are the "agreement" between a service and its consumer. At an abstract level, the contract defines how the data will be exchanged between the two and also defines what data is returned for each type (that is, serialized to XML). For a service and its consumer to communicate, they do not necessarily have to share the same types; they need to share only the data contracts. The default serialize engine in WCF is the data contract serializer, which is implemented as the DataContractSerializer class and is the recommended way to go for WCF. All .NET primitive types can be serialized without any other requirement. However, new complex types need to have an associated data contract defined before they can be ...

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.