Chapter 6: Maintaining Service Contracts and Data Contracts


image from book Download CD Content

Overview

After completing this chapter, you will be able to:

  • Describe how to protect the individual operations in a service contract.

  • Explain which changes to a service require client applications to be updated.

  • Implement different versions of a service contract in a service.

  • Modify a data contract and explain which changes will break existing client applications.

  • Describe how WCF can generate default values for missing items in a data contract.

In Chapter 1, “Introducing Windows Communication Foundation,” you learned that one of the fundamental tenets of Service Oriented Architectures (SOA) is that services share schemas and contracts, not classes or types. When you define a service, you specify the operations that it supports by defining a service contract. The service contract describes each operation, together with its parameters, and any return types. A WCF service can publish its service contract definition, and a developer can use this information to build client applications that communicate with the service. In a WCF environment, a developer uses the svcutil utility to generate a proxy class for the client from the WSDL description of the service. The client uses this proxy to communicate with the service.

The service contract is only one part of the story, however. The operations in a service contract can take parameters and return values. Client applications must provide data formatted in a manner that the service expects. Many of the primitive types in the .NET Framework have predefined formats, but more complex data types such as classes, structures, and enumerations require the service to specify how client applications should package this information up in messages that it sends to the service and the format for any information sent by the service back to client applications. You encapsulate this information in data contracts. Each complex data type used by a service should have a corresponding data contract. The service publishes this information together with the service contract, and the definitions of each complex type are included in the proxy code generated by the svcutil utility.

You should be able to see how service contracts and data contracts are fundamental parts of a service. If a client application does not understand the set of operations that a service exposes or the type of data used by these services, then it will have severe trouble communicating with the service.




Microsoft Windows Communication Foundation Step by Step
Microsoft Windows Communication Foundation Step by Step (Step By Step Developer Series)
ISBN: 0735623368
EAN: 2147483647
Year: 2007
Pages: 105
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net