Wednesday, 27 May 2015

Why WCF

Introduction
What is WCF Service?
WCF stands for Windows Communication Foundation and is part of .NET 3.0. WCF is a Microsoft platform for building distributed and interoperable applications.
WCF supports multiple languages and multiple platforms.
Why Should We Use WCF Service?
Let’s take these two scenarios:
We have two clients and we need to implement a service for them:
1.     The first client is using Java Application to interact with our service. So for interoperability, this client wants messages in XML format and the protocol to be HTTP.
2.    The second client uses .NET, so for better performance, this client wants messages in binary format and the protocol to be TCP.
Without WCF Service

1.     To satisfy the first client requirement, we use web service.


2.To satisfy the second client requirement, we use .NET Remoting.



These are two different technologies, and have completely different programming models. So the developers have to learn different technologies.
So to unify and bring all technologies under one roof, Microsoft has come with a new programming model called WCF-Windows Communication Foundation.

With WCF

You implement one service and we can configure as many end points as we want to support all the client needs. To support the above 2 client requirements, we would configure 2 end points. In the endpoint configuration, we can specify the protocols and message formats that we want to use.




So, the conclusion is that:
1.     A web service to exchange messages in XML format using HTTP protocol for interoperability
2.    A remoting service to exchange messages in binary format using TCP protocol for performance
Along the way, we will get a feel of how different these technologies are.
And last, we will discuss implementing a single WCF Service and configuring different ‘end points to support different transport protocols and message formats.




I am writing this article to understand the basic need of WCF web service. This will explain you why we need WCF web service not the what is WCF web service. You will get n numbers of article over the internet which are explaining what is WCF web service. I am seeing many new freshers in .NET technology who want to learn this technology only because it is hot in the market but not aware that why exactly we need WCF web service.

Let’s come to the point now. First I will tell you the drawback of simple web services.

Suppose I have two clients. One’s requirement is that, he wants to use web service which is implementing HTTP protocol to transfer the information over the network and want the replied output in the form of XML format. To fulfill his requirement I simply develop the web service (which having extension .asmx). This will provide the complete solution to the user.



While my second client wants to use web service which is implementing TCP protocol to transfer the information over the network and want the replied output in the form of binary format. To fulfill his requirement I simply develop the .net remoting web service. This will provide the complete solution to the user.



Here the scenario is that to accomplish these two requirement of user developer need to develop two different types of web services. Developer need to learn two technology.

Here’s the WCF web service comes into picture. Both above requirements is fulfilled by single WCF web service. We don’t need to develop two different web services. We can specify the protocols names in endpoint attribute of the WCF web service (again what is the endpoint is I need to write new article) but just understand the high level requirement. By writing only one WCF web service and specifying the which protocol we want to use while calling the web service is easy as compare to writing two different web services.

That is why Microsoft introduces WCF web service in .NET framework 3.0.

I hope this, by this scenario , you will come to know that why exactly we need WCF web service.

Please post a comment if still you have confusion about this article or like.






No comments:

Post a Comment