Click here to Skip to main content
Click here to Skip to main content

WCF Services - Choosing the appropriate WCF binding

, 30 Jul 2012
Rate this:
Please Sign up or sign in to vote.
Existing bindings available in WCF.

Windows Communication Foundation is a programming model that enables us to develop and then expose our services in a variety of different ways. It means a single WCF service can be exposed with different wire formats and message protocols. Bindings in WCF actually defines that how to communicate with the service. So, binding specifies that what communicate protocol as well as encoding method will be used. Optionally, it can specify other important factors like transactions, reliable sessions and security.

WCF comes with a number of built-in bindings that we can use to expose our service, but WCF is extensible so we can define our own custom bindings to fulfill specific needs.

In this article, we will keep our focus on learning about existing bindings available in WCF. But instead of explaining those bindings in general, we will try to understand these bindings with respect to some suitable scenarios in which it can be used. For understanding WCF Binding internals, another WCF article has these details.

Interoperability Scenario

If we are going to develop a WCF service that will be consumed by non-WCF client applications, then we can expose our service using BasicHttpBinding or WsHttpBinding. So, how these two bindings differ from each other is explain as:

  1. BasicHttpBinding is designed to replace ASMX Web services. It supports both HTTP and Secure HTTP. As far as encoding is concerned, it provides support for Text as well as MTOM encoding methods. BasicHttpBinding doesn’t support WS-* standards like WS-Addressing, WS-Security and WS-ReliableMessaging.
  2. WsHttpBinding also supports interoperability. With this binding, the SOAP message is, by default, encrypted. It supports HTTP and HTTPS. In terms of encoding, it provides support for Text as well as MTOM encoding methods. It supports WS-* standards like WS-Addressing, WS-Security and WS-ReliableMessaging. By default, reliable sessions are disabled because it can cause a bit of performance overhead.
  3. WsDualHttpBinding has all features of WsHttpBinding with addition that it supports Duplex MEP (Message Exchange Pattern). In this MEP, service can communicate with client via callback. Its basically a two way communication.
  4. Note: For further details on Message Exchange Patterns, you can refer my other article “WCF-Top 10 Interview Questions” which explains MEPs in details.

  5. WsFederationHttpBinding is a specialized form of WS Binding that offers support for federated security.
  6. Single Computer Scenario

    If our WCF service resides on a single computer, then netNamedPipeBinding will be the best choice.

  7. NetNamedPipeBinding is secure and reliable binding on a single WCF computer across process communication. It provides support for binary encoding which is the best choice in this scenario and uses named pipes as transport for SOAP messages.
  8. Intranet/Cross Computers .NET Communication Scenario

    If we need to communicate across computers with same .NET technology on intranet, then netTcpBinding or netPeerTcpBinding options are available. It’s basically the replacement or enhancement of earlier .NET Remoting technology.

  9. NetTcpBinding supports reliability, transactions and security. It also supports TCP protocol and binary as encoding method. We can say that it’s the most optimized or fastest binding because both client and service are on the same WCF technology.
  10. NetPeerTcpBinding supports features as that of netTcpBinding but it provides secure binding for peer-to-peer environment with WCF Services.
  11. Disconnected Queued Scenario
  12. NetMsmqBinding is required in a cross machine environment with secure and reliable queued communication. This uses MSMQ as transport.

Other WCF Service articles that might be of your interest:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates United Arab Emirates
Imran Abdul Ghani has more than 10 years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET(MCSD.NET) since 2005. You can reach his blogging at WCF Tutorials, Web Development.
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralMy vote of 3 PinmemberDinesh921-Jan-14 17:19 
QuestionExcellent PinmemberMunazzahNawaz14-Nov-13 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 30 Jul 2012
Article Copyright 2012 by Imran Abdul Ghani
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid