Pages

Wednesday, December 10, 2008

WCF Fundamentals

As the Services need to communicate with clients by sending and receiving messages, naturally in WCF consists of three main concepts:
• Services: Programs that respond to clients. They can send or receive messages.
• Clients: Programs that ask for a service. They can send or receive messages.
• Intermediaries: Programs that works as link between services and clients, for example, they can work as a firewall or can rout messages.
As a developer you will be writing the clients and services. WCF generally takes care of the intermediaries and the messaging. A service can have more than one client and each service can be a client of another service. As you can see WCF is mainly about communication between services provided over the web, you will come across some important concepts like Channels, Bindings, Contracts, Behaviors, Addresses and Endpoints time and again.
Windows Communication Foundation has five-layer architecture. Developers with different skills generally work on different layers. These layers top to down are:
• Application Layer: the application is located in the topmost layer.
• Contracts Layer: below the application layer is the contracts layer where the data and message contracts and bindings and policies are present. In this level services describe themselves to clients.
• Runtime Layer: this layer loads the services and defines the Behaviors.
• Messaging Layer: as the name suggests this layer is responsible for communication between services and deals with different channels and encoding.
• Hosting Layer: this layer contains the host services. You can host a service in two ways.
? You can host a service in Internet Information Services (IIS). This way your services are started and stopped automatically.
? You can create executable files (.EXE) for services and start and stop them manually by writing codes.
There are three programming approaches in Windows Communication Foundation:
• Imperative: You use programming codes in different languages to accomplish a task.
• Configuration Based: You use configuration files to do things.
• Declarative: You use attributes to declare something.
Generally, contracts and behaviors are declared using attributes, configure endpoints, security and some other settings in configuration files and service methods logic are implemented in codes. There are typed services and untyped services. In typed services normal objects and data types are passed and returned, and in untyped services the messages are passed and returned in the lower level.
If you are working with Visual Studio 2005, then you will have to install Visual Studio 2005 xtensions for .NET Framework 3.0 WCF and WPF. After installing this package, you will have new project templates in your Visual Studio to start developing for Windows Communication Foundation.
And if you are working with Visual Studio 2008, you get the new templates for WCF services, in the create web site dialog box.

No comments: