Introduction To WCF

This article is an introduction to WCF: what WCF is, why WCF and various other details regarding WCF.

What is WCF?

WCF stands for Windows Communication Foundation and is a part of the  .NET 3.0 onwards framework. WCF is a Microsoft platform to build the distributed and interoperable Applications.

Now, let’s understand what we mean by the distributed Applications. 

What is a Distributed Application?

In simple terms, a distributed Application is an application where part of it runs on two or more computer nodes. Distributed Applications are also called connected systems.

Now, let’s see some examples, shown below.

Example 1

Look at the diagram where a Web Application is running on the machine, and a Web Service this Web Application is consuming, is running on another machine, so this is a connected system.

Example 2

An enterprise Web Application may have the tiers mentioned below and each tier may be running on a different machine or a Server.

  • Presentation Tier
  • Business Tier
  • Data Access Tier

Now, you may be wondering why somebody would break down any Application into tiers and deploy those tiers in different machine, which is to improve the scalability of their Applications. Let’s understand what do we mean by scalability? 

What is scalability?

Scalability means as the number of users increase, we don’t want the performance of our Application to degrade.
For example, If you have few visitors to your Application, you can deploy all these three tiers on a single machine or Server as they can handle those requests. If there is a traffic and you are expecting more that 100K visitor on your Application, it is advisable to deploy these on different Servers or machines for which you need hardware to process those requests. Hence, these Servers have their own hardware or processors to process those requests.

This makes your Application more scalable because presentation logic is running on a different machine. Business Tier is running on a different machine and Data Access is running on the different machine. Instead of having all these logics running on a single machine, if we deploy those on the different machine, it will be able to handle more and more requests without degrading the performance of your Application.

The next question is why would some body want to build distributed Applications?

  1. An enterprise Application may need to use the Services provided by the other enterprises.

    An ecommerce site may be using PayPal Service for the payment.

  2. An enterprise Application may have Presentation tier, Business tier, Data Access Tier and each tier may be running on different machine.

What is interoperable Application?

An Application, which can communicate with any other Application is built on any platform and is referred as an interoperable Application.

Web services are interoperable, whereas .NET remoting Services are not. The Web Services can communicate with any other Application built on any other platform, whereas a .NET remoting Service can be consumed only by other .NET Application.

What technology choices we have before WCF to build the distributed Applications are shown below.

  • Enterprise Services
  • .NET Remoting
  • Web Services

Why we should use WCF?

Example 1

Hence, we have two clients and we need to implement a Service for them. The first client is using a Java Application to interact with our Service, so for interoperability, this client wants the messages to be in XML format and the protocol will be HTTP.

Without WCF, to satisfy first client requirement, we would end up implementing an ASMX Web Service.

Example 2

The second client uses .NET, so for better performance, this client wants messages formatted in binary over TCP protocol. To satisfy the second client requirement we end up implementing a remoting service.

Web Services and .NET remoting Services are two different technologies and have complete different programming models. The developers must learn different technologies.

In order to unify and bring all these communication technologies under one roof,  Microsoft has come up with a single programming model, which is referred to as WCF – Windows Communication Foundation.

With WCF,

We implement one Service and we can configure as many end points as we want to support all the client needs. To support the above two client requirements, we would configure two end points. In the endpoint configuration, we can specify the protocols and message formats, which we want to use.

Similar Articles