WCF 4 Binding Decision Tree

WCF bindings describe the set of rules that client and service agree upon in order to communicate. The set of rules to use is determined by the most restrictive of the two. This blog post is meant to assist you in making the right decision.

There are already some good examples on the internet, like this one, but they are limited to WCF 3. To have a customizable drawing available and to extend the drawing with the WCF 4 bindings, I decided to make my own.

Although more aspects determine the exact binding, it is my experience that in about 90% of the cases there are basically 2 questions you need to answer:

  • Is it an intranet or an internet facing service?
  • Do you need to support legacy clients or not?

For intranet scenarios you’ll end up with the netTcpBinding most of the time. If you need to support legacy clients then the only alternative is basicHttpBinding, otherwise wsHttpBinding is what you need.

image

The bindings in this diagram are the default bindings. If you want to customize for example the basicHttpBinding to be secure, then you actually create a custom binding based on a default binding. If you change things like that you need to have the bindings configuration in the web.config, which can be omitted if you go for the default binding.

On MSDN there is a great resource with information about the so called system provided bindings. The table below is also taken from there.

Binding

Inter

operability

Mode of Security (Default)

Session (Default)

Trans

actions

Duplex

BasicHttpBinding

Basic Profile 1.1

(None), Transport, Message, Mixed

None, (None)

(None)

n/a

WSHttpBinding

WS

None, Transport, (Message), Mixed

(None), Transport, Reliable Session

(None), Yes

n/a

WS2007HttpBinding

WS-Security, WS-Trust, WS-SecureConversation, WS-SecurityPolicy

None, Transport, (Message), Mixed

(None), Transport, Reliable Session

(None), Yes

n/a

WSDualHttpBinding

WS

None, (Message)

(Reliable Session)

(None), Yes

Yes

WSFederationHttp

Binding

WS-Federation

None, (Message), Mixed

(None), Reliable Session

(None), Yes

No

WS2007FederationHttp

Binding

WS-Federation

None, (Message), Mixed

(None), Reliable Session

(None), Yes

No

NetTcpBinding

.NET

None, (Transport), Message,

Mixed

Reliable Session, (Transport)

(None), Yes

Yes

NetNamedPipeBinding

.NET

None,

(Transport)

None, (Transport)

(None), Yes

Yes

NetMsmqBinding

.NET

None, Message, (Transport), Both

(None)

(None), Yes

No

NetPeerTcpBinding

Peer

None, Message, (Transport), Mixed

(None)

(None)

Yes

MsmqIntegration

Binding

MSMQ

None, (Transport)

(None)

(None), Yes

n/a