WCF

WCF Bindings – What are Different Bindings Supported by WCF?

Read 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,

BasicHttpBinding

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

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

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.

WSFederationHttpBinding

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.

MsmqIntegrationBinding

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.

NetMsmqBinding

Communication between WCF applications by using queuing. Supports transactions

NetNamedPipeBinding

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.

NetPeerTcpBinding

This WCF binding is to address peer-to-peer computing using WCF services. There are Supports for the duplex mode of communication.

NetTcpBinding

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
BasicHttpBindingReplaces Web serviceshttp & https TextNoneNoNo supportNot supported
WSHttpBindingSupports interoperability. With this binding, the SOAP message is encrypted by default.http & https TextMessageOptionalYesNot supported
WSDualHttpBindingSupport all the features of WsHttpBinding with addition that it supports Duplex MEP (Message Exchange Pattern)http & https TextMessageYesYesYes
NetTcpBindingFastest binding because both client and service are on the same WCF technologytcpBinaryTransportOptionalYesNot supported
NetNamedPipeBindingSecure and reliable binding on a single WCF computer across process communicationNamed PipeBinaryTransportYesYesNot supported
NetMsmqBindingUsed in a cross machine environment with secure and reliable queued communication. Works if you have WCF on both ends of the queueMSMQBinaryTransportYesYesNot supported
WsFederationHttpBindingSpecialized form of WS Binding that offers support for federated securityhttp & httpsTextMessageYesYesNot supported
NetPeerTcpBindingSupports features of netTcpBinding. It provides secure binding for peer-to-peer environmentP2PBinaryTransport
MsmqIntegrationBindingProvides queuing support by routing messages through MSMQ. Intended for use with existing, already-written native MSMQ applicationsMSMQNo supportTransportYesYes
Different Types of WCF Bindings

Summary

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 to you shortly.

You may be interested in the article What Is Windows Communication Foundation (WCF)?

Rajeev

Recent Posts

OWIN Authentication in .NET Core

OWIN (Open Web Interface for .NET) is an interface between web servers and web applications…

1 year ago

Serializing and Deserializing JSON using Jsonconvertor in C#

JSON (JavaScript Object Notation) is a commonly used data exchange format that facilitates data exchange…

1 year ago

What is CAP Theorem? | What is Brewer’s Theorem?

The CAP theorem is also known as Brewer's theorem. What is CAP Theorem? CAP theorem…

1 year ago

SOLID -Basic Software Design Principles

Some of the Key factors that need to consider while architecting or designing a software…

1 year ago

What is Interface Segregation Principle (ISP) in SOLID Design Principles?

The Interface Segregation Principle (ISP) is one of the SOLID principles of object-oriented design. The…

1 year ago

What is Single Responsibility Principle (SRP) in SOLID Design Priciples?

The Single Responsibility Principle (SRP), also known as the Singularity Principle, is a software design…

1 year ago