WCF Services: Types of Bindings

Description Article

The WCF Binding represents the HOW of the endpoint ABC. It defines how the service can be accessed and communication is achived (e.g. what transport protocol, encoding and security to use).


How to bind ?

Each of the binding types uses a different transport scheme and encoding. The built-in common binding types are described next:


Name Purpose Scenario Remarks
BasicHttpBinding Designed to replace ASP.Net Web Services (asmx). It support HTTP. and secure HTTP Interoperability scenario Uses SOAP 1.1. By default data is sent as plain textFull compatibility with Clients that still doesn’t run .NET 3.0. Does not support reliable messaging: response order is not guaranteed
wsHttpBinding The SOAP message is by default encrypted. It support HTTP and secure HTTP. The secure HTTP (https) is enabled at Client side by configuring the “wsHttpBinding” binding Interoperability scenario Uses SOAP 1.2. By default data is sent encryptedRequires .NET 3.0. Reliable messaging
webHttpBinding Expose WCF Web services through HTTP requests that use “plain old XML” (POX) style messaging instead of SOAP-based messaging Interoperability scenario / ReST services The endpoint of the service must be configured with the WebHttpBinding that has the WebHttpBehavior attached to it. The WCF service operations must be dcorated with the WebGetAttribute or WebInvokeAttribute attributes.
netTcpBinding/netPeerTcpBinding Secure, reliable, high-performance communication between WCF software entities across a network. Uses TCP as transport protocol-Designed to replace the .NET Remoting technology Best choice to intranet scenario
NetNamedPipeBinding Secure, reliable, high-performance communication between WCF software entities on the same machineUses named pipes as transport protocol Best choice for single computer scenario
NetMsmqBinding Secure and reliable queued communication using MSMQ as transport protocol. Disconnected scenario.
mexHttpBinding Returns service metadata using HTTP as transport protocol.
mexTcpBinding Returns service metadata using Tcp as transport protocol.
mexNamedPipeBinding Returns service metadata using named pipes as transport protocol.

Note: Custom bindings can be implemented to represent addicional transport protocols by implementing the class CustomBinding

How to choose the appropriated WC binding type ?

To achive the best performance and the appropriated binding type the following features must be considered:

  • The service needs to interact with non-WCF clients ?
  • The clients expect the basic old web service protocol (ASMX web services) ?
  • The non-WCF clients can understand WS-* standards these standards ?
  • The WCF client requires connected or instead offline or disconnected interaction ?
  • The client is on the same machine as the service ?

The following diagram can be followed: