WCF Contracts

Posted: October 22, 2007  |  Categories: Uncategorized WCF

In previous post I talked about my exploration (and/or study) of WCF. I have started with building WCF services and so on (see list below).

  • Defining service contracts and services
  • Hosting of services in a console app or IIS
  • Exposing of endpoints for services using various standard bindings
  • Working with VS templates and tools (SvcUtil, Service Configuration Editor)
  • Service metadata (browsing)
  • Configuration of service behaviors
  • Generate proxies and invoking services
  • Now I am going deeper into contracts and study messaging protocols (TCP, MSMQ, HTTP or named pipes), SOAP, WS*, WSDL and so on. WCF relies on standards to serialize messages, for instance SOAP (1.1 or 1.2) which describes a general format for messages. When messages need to be secure and reliable WS-* plays an essential role. There is a long list of WS-* protocols and some of them are well-adopted like WS-Addressing, WS-MetadataExchange, WS-Policy, MTOM, WS-Security, WS-Trust and WS-SecureConversation, WS-Reliable Messaging and WS-AtomicTransaction. All of them are very lengthy described in documents and can found at W3C or OASIS. A shorter version or overview I found in for instance an msdn article written by Aaron Skonnard. I have downloaded the code of that same article and had a spin on it using VS 2008 Beta 2. Converting the code to use in VS 2008 was no problem and sample worked fine. There are some more great explanations of reliable messaging on the web like Reliable Messaging Simplified and WCF: Reliable Message Delivery. Another great article (overview) about WS-* can be found at InfoQ written by Michele Leroux Bustamante (yep same as author of Learning WCF I currently reading and doing WCF labs from).

    Services implement one or more endpoints, each supporting different set of operations, messaging protocols, message encoding formats and transport protocols. Well this information about a service is part of its metadata and can be viewed as the service description. WCF represents this info at runtime as ServiceDescription type from System.ServiceModel namespace. This type is used to generate the WSDL document. Through SvcUtil proxies can be generated for clients through (A) WS-MetadataExchange or (B) a WSDL document.

    In WCF application requirements are described by contracts and there are three types that clients (consumer) and services (provider) rely on to control messaging.

  • Service Contract : describe operations exposed by particular endpoint
  • Data contract : describe how complex type is serialized
  • Message contract : provide control over format entire SOAP message
  • See also Wikipedia and msdn.

    Service Contract describes operations supported by a service, message exchange patterns used and format of each message. A WCF service has at least one service contract and the following attributes play an important role in defining it: ServiceContractAttribute, OperationContractAttribute and MessageParameterAttribute. These attributes provide control over the way messages are formatted. In a lab inside learning WCF book this exercised. And that is what I am going to now.


    Author: Steef-Jan Wiggers

    Steef-Jan Wiggers is all in on Microsoft Azure, Integration, and Data Science. He has over 15 years’ experience in a wide variety of scenarios such as custom .NET solution development, overseeing large enterprise integrations, building web services, managing projects, designing web services, experimenting with data, SQL Server database administration, and consulting. Steef-Jan loves challenges in the Microsoft playing field combining it with his domain knowledge in energy, utility, banking, insurance, healthcare, agriculture, (local) government, bio-sciences, retail, travel, and logistics. He is very active in the community as a blogger, TechNet Wiki author, book author, and global public speaker. For these efforts, Microsoft has recognized him a Microsoft MVP for the past 8 years.


    Back to Top