O'Reilly logo

Professional WCF 4: Windows Communication Foundation with .NET 4 by Johann Grabner, Fabio Cozzolino, Kurt Claeys, Pablo Cibraro

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 2. Service Contracts and Data Contracts

WHAT'S IN THIS CHAPTER?

  • Explaining contracts

  • Implementing service contracts

  • Implementing data contracts

  • Using different serializers

  • Implementing message contracts

Contracts in general are very important in our daily lives. Contracts ensure that each party is aware of what his or her efforts will return. If you put your signature at the end of 17 pages of a business document or make a verbal agreement, expectations are given and agreed on. A contract should be well-defined and understandable without leaving any leeway for interpretation.

One thing is certain: in a service-oriented environment where different parties (software components) communicate with each other and use different technologies and platforms, it is indispensable to have a clear definition of the how and what.

WCF (Windows Communication Foundation) uses the concept of contracts to define the service and its operation as a whole, to explain the data which are transferred by wire, and if needed, to directly define the SOAP messages exchanged between the client and the service. WCF uses WSDL and XSD to deliver service metadata.

WCF differentiates between three types of contracts: service, data, and message.

Each of these contracts defines a certain behavior. The one needed depends on your architecture. The most frequently used contract type is the service contract — it can be used in nearly every scenario. The service contract also stands for the C in the ABC of an endpoint. As ...

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