Understanding Windows Communication Foundation

Started by thiruvasagamani, Dec 02, 2008, 10:51 PM

Previous topic - Next topic

thiruvasagamani

Understanding Windows Communication Foundation

This article provides an introduction to Windows Communication Foundation (WCF) followed by a list of what's new for WCF in .NET Framework 3.5. In the companion topic, Developing Connected Systems, the concepts discussed here are illustrated with code from the DinnerNow.net sample application. The Windows Vista Developer Story article Windows Communication Foundation contains additional background information.

Overview


Windows Communication Foundation, a core component of .NET Framework 3.0, provides a service-oriented programming model, run-time engine, and tools for building connected applications. WCF unifies and extends the functionality of existing Microsoft connecting technologies by providing a single programming model independent of underlying communications protocols. WCF applications use open standards and protocols to interoperate with existing Microsoft and non-Microsoft technologies.

WCF models network communication that consists of message exchanges between a client and a service. When a client sends a message, it travels through multiple layers of software, each performing some operation on the message, before being transported across the network to the server. At the server, the message again travels through multiple layers of software before being delivered to the service. These multiple layers of software are known as the communication stack. Each layer is governed by one or more standards or protocols, which specify the end result of the operation on the message at that layer.

In WCF, the communication stack is represented as a binding. A binding consists of a set of binding elements, each of which represents a layer in the stack. The implementation of a binding element is known as a channel. At run time, WCF assembles the stack of channels specified by the binding. When data is sent, WCF translates the data into a message and passes the message through the stack of channels, so that the message is sent in accordance with the protocols identified by the binding. This process is reversed on the receiving end.

The core concept behind WCF is the service, which is a .NET type that implements one or more service contracts with each contract exposed through an endpoint.
Endpoints

An endpoint expresses all the information needed by a client to communicate with a service. An endpoint consists of an address, a binding, a contract, and optional behaviors.

The address specifies where the service is located for a specific service contract. The binding declares the set of protocols that are used to send and receive messages. The contract defines the kind of messages that can be sent and received. Behaviors control optional service and client functionality.

Endpoints can be defined programmatically or in an XML configuration file. WCF provides the Service Configuration Editor (SvcConfigEditor.exe) tool to aid in the creation and modification of endpoint XML definitions as well as other settings. The following portion of an XML configuration file shows an example of two endpoint definitions, which are discussed in subsequent sections.
Copy Code

<service name="ProcessOrder">
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost:10021/dinnernow" />
    </baseAddresses>
  </host>
  <endpoint
    address="orderProcess"
    binding="wsHttpContextBinding"
    contract="IProcessOrder" />
  <endpoint
    address="mex"
    binding="mexHttpBinding"
    contract="IMetadataExchange" />
</service>
Thiruvasakamani Karnan