O'Reilly logo

Programming WCF Services by Juval Lowy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Data Contracts

In the abstract, all that WCF provides for is the ability to host and expose native CLR types (interfaces and classes) as services, and the ability to consume services as native CLR interfaces and classes. WCF service operations accept and return CLR types such as integers and strings, and the WCF clients pass in and process returned CLR types. However, such CLR types are specific to .NET, of course. One of the core tenets of service-orientation is that services do not betray their implementation technology across the service boundary. As a result, any client, regardless of its own technology, can interact with the service. This obviously means that WCF cannot allow you to expose the CLR data types across the service boundary. What you need is a way of converting CLR types to and from a standard neutral representation. That representation is a simple XML-based schema or an infoset. In addition, the service needs a formal way for declaring how such conversion is to take place. This formal way is called a data contract, and it is the subject of this chapter. This first part of the chapter shows how data contracts enable type marshaling and conversions and how the infrastructure deals with class hierarchies and data contract versioning. The second part shows how to use various .NET types such as enumerations, delegates, data tables, and collections as data contracts.

Serialization

The data contract is part of the contractual operations the service supports, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required