Introduction to Windows Communication Foundation (WCF)
The Windows Communication Foundation (or WCF), is an application programming interface in the .NET Framework for building connected, service-oriented applications. The global acceptance of Web services, which includes standard protocols for application-to-application communication, has changed software development. For example, the functions that Web services now provide include security, distributed transaction coordination, and reliable communication. The benefits of the changes in Web services should be reflected in the tools and technologies that developers use. Windows Communication Foundation (WCF) is designed to offer a manageable approach to distributed computing, broad interoperability, and direct support for service orientation.
WCF simplifies development of connected applications through a new service-oriented programming model. WCF supports many styles of distributed application development by providing a layered architecture. At its base, the WCF channel architecture provides asynchronous, untyped message-passing primitives. Built on top of this base are protocol facilities for secure, reliable, transacted data exchange and broad choice of transport and encoding options.
Windows Communication Foundation (WCF/Indigo), Windows Presentation Foundation (WPF/Avalon), CardSpace (InfoCard) and Windows Workflow Foundation (WF/Workflow) are the four pillars of .Net 3.0. The below figure shows the .Net 3.0 stack.
WCF is designed in accordance with Service oriented architecture principles to support Distributed computing where services are consumed by consumers. Clients can consume multiple services and services can be consumed by multiple clients. Services are loosely coupled to each other. Services typically have a WSDL interface which any WCF client can use to consume the service, irrespective of which platform the service is hosted on. WCF implements many advanced web services (WS) standards such as WS-Addressing, WS-ReliableMessaging and WS-Security.
A WCF Service is composed of three parts — a Service class that implements the service to be provided, a host environment to host the service, and one or more endpoints to which clients will connect. All communications with the WCF service happens via the endpoints. The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted.
In Windows Vista, Windows Server 2008 and Windows 7 (operating systems that include IIS 7), Windows Activation Services can be used to host the WCF service. Otherwise the WCF service can be hosted in IIS, or it can be self-hosted in any process by using the ServiceHost class, which is provided by WCF. A self-hosted WCF service might be provided by a console-based application, a Windows Forms application, or a Windows service (the Windows counterpart to a daemon), for example.
A WCF client connects to a WCF service via an endpoint. Each Service exposes its Contract via one or more endpoints. An endpoint has an address, which is a URL specifying where the endpoint can be accessed, and binding properties that specify how the data will be transferred.
The mnemonic "ABC" can be used to remember Address / Binding / Contract. Binding specifies what communication protocols are used to access the service, whether security mechanisms are to be used, and the like. WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues etc.
When a client wants to access the service via an endpoint, it not only needs to know the Contract, but it also has to adhere to the binding specified by the endpoint. Thus, both client and server must have compatible endpoints.
Hosting WCF Services
WCF is part of the .NET Framework 3.0 stack and thus is supported on the following operating platforms: Windows XP/SP2, Windows Vista, Windows Server 2003, and Windows "Longhorn" Server. Regardless of platform, you can access WCF services over many protocols including HTTP, TCP, IPC and MSMQ. Unfortunately, not all hosting environments are available to each platform, nor does every host support the entire suite of protocols limiting your options at times.
Beyond operating platform and choice of protocol, other features available to the hosting environment also influence deployment decisions and choice of host. In this article, I will describe the desired features of a hosting environment; provide you with an overview of WCF hosting options and their availability; and explain how to implement scenarios applicable to each environment.
Features of a Great Host
Hosting environments make it possible to expose your services to client applications. They facilitate request processing to service operations, but they can also play a critical role in the availability and scalability of your services. A great hosting environment should provide these important features:
There are three generic categories of hosts for your WCF services:
The term "self-hosting" refers to any application that provides its own code to initialize the hosting environment. This includes console, Windows Forms, WPF, and managed Windows services. Table 1 provides a summary of these three hosting environments and the features they support.
At a minimum, all WCF hosts provide an executable process and application domain in which services are loaded. They also provide support for external configuration. The remaining hosting features discussed here are built into IIS and WAS, but not provided by self-hosting environments. Despite this fact, self-hosting does have its value under the right circumstances.
Hi Nishikant, thanks for posting such a nice articles.
-- Manisha Chaubey
Thanks Nishikant for posting detailed and understandable information about the Windows Communication Foundation.
Nice Article to understand easy as well
thanks nisikant for posting a very good article,it is very usefull........
Thanks for your compliments !!!! :-)