ItRead this article for understanding various types of WCF bindings.
WCF Bindings describes how clients can communicate with WCF service. A WCF binding defines the communication between end points and the world.Binding includes transportation and the encoding like text and binary.
Bindings in WCF define how external world/other endpoints can communicate with the service.WCF binding specifies what communication protocol as well as what encoding method will be used. Optionally, it can specify other important factors like transactions, reliable sessions, and security.
Different types of WCF bindings
WCF binding is a set of binding elements which specifies how the client and service communicate each other.Each binding has at least a transport element and a message encoding element.
Here in this post, we are addressing the questions such as,
What are Different Bindings Supported by WCF?
What are the bindings available in WCF?
What are Windows Communication Foundation Bindings?
How to choose a WCF binding? When to use which binding in WCF ?
Continue reading various types of WCF Bindings explained in detail below,
Basic HTTP binding is mainly meant for backward compatibility so that older .NET version applications such as asmx web services can consume this binding based service. BasicHttpBinging no security as such by default.That means data is sent as plain text over HTTP.
Basic Http Binding does not support WS-* specifications and hence this binding is not secure.No transaction support and not suitable for reliable messaging.Message transport is SOAP 1.1 based.
BasicHttpBinding has no security as such by default.That means data is sent as plain text over HTTP.
WsHttpBinding uses SOAP 1.2 version and implements WS-* specifications.Hence this binding has the support of security (data transfer in secure encrypted manner, no plain text transport), reliable messaging and also transaction support.
.NET versions prior to 3.0 won’t be able to consume wshttpbinding based services since older versions cannot understand WS-* specifications.
WsDualHttpBinding is similar to WsHttpBinding with an added support of duplex communication mode. So this binding appropriate for duplex service implementation over HTTP protocol.
Duplex services use duplex message pattern to have a two-way communication between service and client through a callback mechanism.
Federated security permits association across multiple systems, networks, and organizations in different trust realms by a clean separation of the service a client is accessing and the associated authentication and authorization mechanisms.
By means of WSFederationHttpBinding, WCF supports in building and deploying distributed systems that can work with federated security.
wsFederationHttpBinding binding also implements WS-* specifications and hence provides allows to implement a secure, reliable, and interoperable service. HTTP protocol is used for message transport.
A binding to communicate directly with MSMQ applications.MsmqIntegrationBinding is for queued communication using MSMQ transport.
This binding is also secure & reliable.Allows enables for disconnected operations, failure isolation and load leveling.
If you have an application which is writing to Queue and want the WCF service to pick messages from the Queue this binding is appropriate.
Communication between WCF applications by using queuing. Supports transactions
This binding is appropriate for communication between WCF services and WCF client on the same machine or for communication between two WCF services running on the same machine. It uses NamedPipe protocol.
NetNamedPipeBinding has Support for duplex communication mode and also transactions support. Secure, reliable and transaction supported.
This WCF binding is to address peer-to-peer computing using WCF services.There are Supports for the duplex mode of communication.
This WCF binding sends SOAP 1.2 messages, provides binary encoding and optimized communication between WCF services and WCF clients on Windows network.
NetTcpBinding is one of the fastest WCF bindings amongst all WCF bindings options between different nodes in the TCP network. Unlike HTTP bindings, the TCP binding does not offer interoperability but is highly optimized for .Net 3.0 and above clients.
Thus, in .Net version 3.0 and above, providing an endpoint with NetTcpBinding is an easy option to development of distributed systems and can replace COM+ and .Net Remoting model.
Choose Appropriate WCF binding for Your WCF Service
Depending upon your requirements, you can choose a binding most suitable for you.Here is a flow chart that will assist you in choosing appropriate WCF binding for your application.
Image Credit: mohammedatef.files.wordpress.com
WCF bindings comparison
See the WCF bindings comparison in tabular form below,
|WCF Binding||Description||Transport Protocol||Message Encoding||Security Support||Default Session||Transaction Support||Duplex Communication|
|BasicHttpBinding||Replaces Web services||http & https||Text||None||No||No support||Not supported|
|WSHttpBinding||Supports interoperability. With this binding, the SOAP message is encrypted by default.||http & https||Text||Message||Optional||Yes||Not supported|
|WSDualHttpBinding||Support all the features of WsHttpBinding with addition that it supports Duplex MEP (Message Exchange Pattern)||http & https||Text||Message||Yes||Yes||Yes|
|NetTcpBinding||Fastest binding because both client and service are on the same WCF technology||tcp||Binary||Transport||Optional||Yes||Not supported|
|NetNamedPipeBinding||Secure and reliable binding on a single WCF computer across process communication||Named Pipe||Binary||Transport||Yes||Yes||Not supported|
|NetMsmqBinding||Used in a cross machine environment with secure and reliable queued communication.Works if you have WCF on both ends of the queue||MSMQ||Binary||Transport||Yes||Yes||Not supported|
|WsFederationHttpBinding||Specialized form of WS Binding that offers support for federated security||http & https||Text||Message||Yes||Yes||Not supported|
|NetPeerTcpBinding||Supports features of |
|MsmqIntegrationBinding||Provides queuing support by routing messages through MSMQ.Intended for use with existing, already-written native MSMQ applications||MSMQ||No support||Transport||Yes||Yes|
In this article, we covered basics of WCF Bindings. We hope this article helped you to get an idea of different WCF Bindings.Choose your suitable WCF Bindings as per your application's demand.
Here we tried to explain different WCF bindings supported by WCF in very simple terms for the understanding of beginners also.If you have any feedback or query on WCF Bindings, feel free to comment below. We will reply you shortly.
You may be interested in the article What Is Windows Communication Foundation (WCF)?