Friday, September 11, 2009

Why do we need WCF

There was a time when applications used to sit on separate computers, then came a need for the different computers to talk to each other. Well we all know that web and web services have long been in there and have been communicating with each other.

We all understand that XML has been adopted as a great medium of communication between web services and their clients. But, in the absence of a protocol, there is no one way to use XML. The sender and receiver of the information have to decide on a certain format for the information every time. It is easier if a global standard is present and the information is shared by default based on that standard.
Web services and client applications communicate with each other by using the Simple Object Access Protocol or SOAP.
SOAP defines the following:

- The format of the SOAP message
- How data should be encoded
- How to send messages
- How to handle replies to these messages

A web service can simply display the messages that a client application can send it and the responses the client application will receive by publishing a Web Service Description Language (WSDL) document.
Now, there are other technologies apart from WCF like .Net Remoting and MSMQ for transfer of information.
What WCF does is provides a unified programming model for many of these technologies, enabling you to build applications that are as independent as possible from the underlying mechanism being used to connect services and applications together. So that the programmatic structure is completely separate from the communication structure.

Now, how does it do that????

So suppose we have a server application and a client application – at the base, we have .Net framework, a set of classes in form of WCF on top and the two interacting with the help of SOAP. By default WCF operations are of the type known as request – reply; the client issues a request in the form of a message and the server responds by replying to the request.


The client need not be based on WCF; it can be J2EE based or anything that supports SOAP. This is a very important point as it supports interoperability with applications built on other technologies.
WCF can also be extended to process plain XML data that is not wrapped in the SOAP envelope. WCF can also be extended to support ATOM or JSON. Thus, we can say WCF is really helpful and is designed to support the present as well as the future scenarios.