Saturday, July 18, 2015

ABC of Windows Communication Foundation

Windows Communication Foundation or WCF was introduced by Microsoft way back in its framework 3.0, with the code name Indigo. But what is WCF and why it was introduced. Let's discuss briefly about it and how it can be created.

For creating distributed applications, we already had the concept of web services, .Net Remoting and MSMQ etc. Which one to be used, depended on the requirement. But, as an implementation, all of them were separate techniques/technologies for use. So Microsoft created a uniform framework which provided all these technologies under a single umbrella called WCF. 

The basic requirements how WCF works is defined by it's three attributes also know as (ABC of WCF). These ABC are defined as:
  • A stands for Address
  • B stands for Binding
  • C stands for Contracts
These three things are what make the WCF a powerful framework.To understand about these, we will try to understand it with a simple real life example. Suppose it's your friend's birthday and you have to attend his party. But before that, you have to plan or you must know some important things for joining the party:

  • Where is the party venue ?
  • How you will be going to the party alone or with other friends ?
  • What will be the gift you will be giving to your friend ?
This is what WCF requires you to know:

  • Where is the party i.e. Where is the WCF service hosted i.e. Address
  • How will you go to the party i.e. How will you communicate with the service i.e. Binding
  • What will be the gift you will be giving i.e. What is the data shared between the client and service i.e. Contracts

So Address is, the service url, which can be of the forms like:
  1. http://localhost:8021/TestService.svc
  2. net.tcp://localhost/TestService.svc
  3. net.msmq://localhost/TestService.svc
So Binding is how the communication will take place with the service. This through the use of different protocols like Http, TCP and msmq etc. These protocols are supported through the use of different bindings like:
  1. BasiHttpBinding
  2. NetTcpBinding
  3. WSHttpBinding
  4. WSDualHttpBinding
  5. WSFederationHttpBinding
  6. NetNamedPipeBinding
  7. NetMsmqBinding
  8. NetPeerTcpBinding
And, Contracts are, what kind of data can be exchanged between the client and service. Contracts can be of following types:

  1. ServiceContract
  2. OperationContract
  3. DataContract
  4. MessageContract
  5. FaultContract

So this was about the ABC of WCF services. Hope you enjoyed reading it. Happy coding...!!!

No comments:

Post a Comment