WCF Services: Choosing the Appropriate WCF Binding

In this article you will see when to choose the binding in WCF.

Hi Friends,

In this section, we'll see when to choose which binding. In the following I have pasted a simple self-descriptive decision tree.

 

Let me explain that. So, before choosing a binding, the first question we'll ask is, are we inside a firewall? Then if the answer is no and we are using .Net to .Net communication then in we can use WsHttpBinding since it supports a complete WS-* stack and is much more feature-rich than the basic one. Now, if the client is not .Net to .Net then do you need to support older versions of Java clients or .Net 2.0 or below? If so then you can use BasicHttpBinding. Here, you won't get any out-of-the box features provided by a WS-* stack but at least you can communicate.

However, if you are inside the firewall and a client is not .Net to .Net, then you can ask the Supporting Older Version question. And if it's a .Net client and inside the Firewall, then the next question is if it exists in the same machine, or in other words is it a local in-process only? If so then you can use NetNamedPipeBinding. And if the client is not on the same machine and it's more conventional, like a server on one machine and the client is on other, then the next question I would ask is whether you need to disconnect. If the answer is yes, then you should use NetMSMQBinding. If the answer is no, then the next question I would ask is whether you need reliability. Now, if you don't require reliability then you can use NetUDPBinding otherwise NetTcpBinding. So, these are the most common use cases of choosing a binding.

Thanks.