When I started working with WCF, I every time gets very much confused among the three terms viz address, binding and contract. Now since I have understood them all, I thought therefore it would be a good idea to write a post on it so as to let others not get confused.
This is going to be just a simple post only concepts and not code. So, lets get started and discuss the three one by one.
Address
What is an Address? Think. Are you thinking what I am thinking? If yes then you are right. Address specifies the location where one lives. If I live near Connaught place New Delhi, then, it’s my address. Now one more question. Once in for all, why do we create Services at all? One answer might be, simply to let others use it. Which is quite acceptable.
But obviously, in order to let others use our service, we need to place it somewhere, somewhere within their reach. And once we place the service at some place, in the reach of everyone, we need to let them know where we have placed our service so that they know exactly where to look for it. That is to say, we need to provide people with the address of the location where we have kept our service. Now since we need to place our service (or host our service, technically speaking) somewhere over the internet, we need to provide people with the Url of it.
So, Address is basically the URL of the server where the service is hosted.
Binding
Binding is something that connects two being with one another. For example, me and my friends has the binding of friendship, me and my girlfriend has the binding of love etc.. The basic concept behind binding is this, “one must speak what other wants to hear.” Until you are following this methodology, your are in a proper binding.
One service can have many clients. May be either JavaScript application or Console Application or Silverlight Application. And in order to keep binding with all the clients, service must be able to speak everything what each clients listens. Like JavaScript application listens JSON, console application listens SOAP etc.. Now since the service is communicating with different clients, it have to have different bindings so that every client must be happy with the services our service provides.
So, Binding is the way by which a service communicates with it’s clients.
Contract
I still remember the day my dad shown me the contract of our house a long back. I read it and it seems to me something like a description of exactly what the house, that is going to be constructed, will look like.
It is like same in our case. A contract defines an outline of what our service is going to do. It tells client exactly how many classes the service has, what methods are exposed and they can use, what will be the outputs of the methods and what the methods will take as input.
So, Contract defines an agreement between service and client, that ensure clients about what the service is going to provide.
This is it!!!
I hope you must have liked reading it. I tried my best to keep it simple as much I can.
Happy Reading!!!
0 comments