Introduction to the Windows Communication Foundation
Services seem to be everywhere these days and even more ways to build them. Windows Communication Foundation (WCF) is the unified .NET programming model for building service oriented applications. It is designed to simplify the creation of connected applications through a service oriented programming model. WCF supports a variety of distributed application development by providing a layered architecture. The base of WCF provides the asynchronous message passing primitives. The higher level services layered on top of this base include secure and reliable messaging exchange, a typed programming model including serialization facilities, queued and transacted messaging exchange, integration with other programming models like MSMQ, COM+ and ASP.NET Web Services, Web Service Enhancements and others. Technically, WCF is implemented as a set of classes starting with the.NET Framework 3.0. The main namespace for working with WCF is the System.ServiceModel. This namespace contains the classes, enumerations and interfaces necessary to build WCF services and client applications.
A Windows Communication Foundation service is provided by defining one or more Windows Communication Foundation endpoints. An endpoint is defined by an address, a binding and a service contract. The address defines where the service is located. The binding specifies how to communicate with the service. The service contract defines the operations that the service can perform. WCF services must be hosted within a process to become active. The hosting environment is responsible to create and control the context and lifetime of the service. WCF services are designed to run in any Windows process that supports managed code. This programming model is designed to remain consistent and is considered independent of the runtime environment that is used to deploy the service. The benefit is that this makes the code for your service look very much the same whatever hosting option is selected.
Typically hosting options range from running inside a console or Windows Form application to server environments running within a worker process managed by IIS. WCF allows developers to choose the hosting environment that meet the needs of their application as opposed to requiring the use of a specific transport or technology.
In this article we will generate a simple WCF service using Visual Studio 2008 and the .NET Framework 3.5 and test it using the built in harnesses.