Types of Bindings in WCF: Encoding Methods and Protocols
Types of Bindings in WCF: Encoding Methods and Protocols
Bindings in WCF define that how to communicate with the service. So, WCF Binding specifies that which communication protocol and encoding method should be used to communicate with the service.
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. WCF Binding can be BasisHttpBinding, WsHttpBinding, WsDualHttpBinding, WsFederationHttpBinding, NetNamedPipeBinding, NetTcpBinding, NetPeerTcpBinding, NetMsmqBinding. Lets look at them in detail:
Types of WCF Bindings
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. WsFederationHttpBinding is a specialized form of WS Binding that offers support for federated security.
5. NetNamedPipeBinding is secure and reliable binding on a single WCF computer across process communication. It provides support for binary encoding which is the best
6. 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.
7. NetPeerTcpBinding supports features as that of netTcpBinding but it provides secure binding for peer-to-peer environment with WCF Services.
8. NetMsmqBinding is required in a cross machine environment with secure and reliable queued communication. This uses MSMQ as transport.