WCF Binding Selection

Windows Communication Foundation(WCF) Services exposes endpoint(s) and each endpoint has information of ABC i.e. Address, Binding and Contract.

Binding defines the underlying protocol, message encoding and transport details which are essential for client and service to communicate with each other. WCF provides several pre-configured bindings having different protocols, encoding scheme etc. Further these bindings can be customized. For details, visit “Windows Communication Foundation Bindings” at MSDN.

The WCF ships with the following pre-configured bindings:

Binding

Description

basicHttpBinding

This interoperable binding is commonly used as a replacement for earlier Web services based on ASMX (Active Server Methods). It supports Hypertext Transfer Protocol (HTTP) and Hypertext Transfer Protocol over SSL (HTTPS) transport protocols as well as text and Message Transmission Optimization Mechanism (MTOM) encoding methods.

wsHttpBinding

This secure and interoperable binding uses SOAP over HTTP and supports reliability, transactions, and security over the Internet. It supports HTTP and HTTPS transport protocols as well as text and MTOM encoding methods.

wsDualHttpBinding

This interoperable binding is commonly used for duplex service contracts because it supports bidirectional communication.

webHttpBinding

This secure and interoperable binding sends information directly over HTTP or HTTPS without creating a SOAP envelope. It is an efficient choice when SOAP is not required by the client.

wsFederationHttpBinding

This secure and interoperable binding supports federated security. It supports HTTP and HTTPS transport protocols as well as text and MTOM encoding methods.

netTcpBinding

This secure binding is used to send binary-encoded SOAP messages from one WCF computer to another. It uses Transmission Control Protocol (TCP) and includes support for reliability, transactions, and security.

netNamedPipeBinding

This secure binding should be used on a single WCF computer. Binary-encoded SOAP messages are sent over named pipes.

netMsmqBinding

This queued binding is used to send binary-encoded SOAP messages over MSMQ. Communication should occur between two computers.

netPeerTcpBinding

This secure binding is used for peer-to-peer communication over TCP. Communication should occur between two or more computers.

msmqIntegrationBinding

This interoperable binding can be used for existing MSMQ applications that use COM and native C++ application programming interfaces (APIs).

basicHttpContextBinding

This binding provides support for HTTP cookies and enables SOAP headers to exchange context.

netTcpContextBinding

This secure binding enables SOAP headers to be used in the exchange of content.

wsHttpContextBinding

This secure and interoperable binding enables SOAP headers to exchange context while also supporting reliability, transactions, and security.

*Table Taken from MCTS 70-503 Windows Communication Foundation By Microsoft Press, Copyright GrandMasters and Microsoft Corporation.

Choosing a Binding for WCF Service may seem confusing, initially, for developers but here is a flow diagram that will help you in selecting binding depending upon your scenario.

clip_image001
Reference: Programming WCF Services by Juwal Lovy- Oreilly

Perhaps the most commonly used in the market are basicHttpBinding and wsHttpBinding which uses SOAP 1.1 and SOAP 1.2 respectively. A good comparison of both these is done by Kurt CLAEYS on his blog. I hope this post cleared the picture in your mind 🙂

Have a Good Day with Services!