63

I'm new to WCF and would like to know the differences/advantages/limitations/etc of each of the following bindings:

net.pipe
net.tcp
http

Supporting scenarios on when to use each binding and other examples would be appreciated.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Aaron
  • 2,427
  • 4
  • 30
  • 41

3 Answers3

69

While not great for providing specific usage examples, here is a link from MSDN which lists all the features for the bindings.

http://msdn.microsoft.com/en-us/library/ms730879.aspx

Here is a decent flow chart that can help choosing between them as well.

Flowchart

Source: http://bloggingabout.net/blogs/dennis/archive/2006/12/01/WCF-Binding-decision-chart.aspx

Here is a good overall article I've used in the past.

http://mkdot.net/blogs/dejan/archive/2008/03/31/wcf-binding-decision.aspx (or here in the wayback machine if the link no longer works for you).

Peter
  • 13,733
  • 11
  • 75
  • 122
Joe Doyle
  • 6,363
  • 3
  • 42
  • 45
  • Michele Leroux Bustamante has a good comparison of all the different bindings with examples in her book: Learning WCF – Arman Bimatov Aug 20 '13 at 15:08
  • 1
    @JoeDoyle While this answer attempts to answer the question, could you kindly improve your answer by adding any relevant excerpts from the referenced links to your answer? It will be helpful to future visitors as they won't need to click through to links and most importantly helps protect your answer against dead links. – Kermit Feb 18 '14 at 18:15
  • I love this, I love this, I simply love this flowchart! Really awesome! – Aditya Bokade Aug 27 '14 at 01:13
  • Last 2 links are not working any more. Is there a chance to replace them with some suitable and relevant articles from somewhere else? thanks for follow up – Tatranskymedved Apr 08 '21 at 10:00
52

net.pipe, fast and secure because your web service is not accessible from the network (typically, you will use net.pipe to interact with a windows service easily).

http, you will use it for interoperability reason, if your web service is not over HTTP, silverlight or flash cannot use it (because the browser filter non-http packets, as a firewall does).

net.tcp, is a bit faster because your soap message is not wrapped inside a HTTP request, but you cannot invoke your webservice with a RIA technology, and some firewall will drop your message.

Nicolas Dorier
  • 7,383
  • 11
  • 58
  • 71
  • Note that if you need operations to get logged by IIS (for statistics for instance), AFAIK, you have no choice but to use http since both net.tcp and net.pipe won't log anything even if configured with IIS as the host. – bkqc May 10 '21 at 15:39
14

Windows Communication Foundation (WCF) is a framework for building services that process XML messages. WCF allows you to transmit messages using different transport protocols (such as HTTP, TCP, and MSMQ) and using different XML representations (such as text, binary, or MTOM, which is commonly referred to as the message encoding in WCF.

If you want to host many WCF Services on one machine and want them to use shared memory for their communication, use a named pipe=>net.pipe, and then use tcp for the communication to WCF Services on different machines.

Configuration of nettcp binding focuses on creating a channel stack that will perform better in Windows environments, giving you a great option for replacing your various COM+ and .NET remoting investments.

BasicHttpBinding was designed for scenarios where interoperability is of utmost importance. As a result, BasicHttpBinding uses HTTP for the transport and text for the message encoding.

Srikar Doddi
  • 15,499
  • 15
  • 65
  • 106
  • 4
    WCF doesn't required XML messages. For example, the messages can be encoded in plain text or binary – jbatista Sep 17 '13 at 16:17
  • MTOM is not the message enconding in WCF. It is an optimization over SOAP messages to prevent from binary data from being Base64'd. It is BasicHttpBinding which is using SOAP (XML). – Oooogi Feb 18 '16 at 08:23