.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> WCF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Introduction of Custom Binding in WCF

Posted By:Dhananjay Kumar       Posted Date: May 17, 2010    Points: 25    Category: WCF    URL: http://www.dotnetspark.com  

Introduction of Custom Binding in WCF. Custom Binding provides the full control over the messaging stack for the user.

This article also published in My BLOG

Theoretical introduction of Custom Binding in WCF

What is Custom Binding?
Custom Binding provides the full control over the messaging stack for the user. We use Custom Binding, when none of the system provided binding is matching our requirement. For example let us say, your requirement is to use Http protocol to send SOAP12 message version.

Each Binding is made of different binding elements. We can construct a Custom Binding from a set of system-provided binding elements. System-provided binding elements are stacked in a specific order and we need to follow that order while creating a custom binding. Few binding elements are optional in the stack and few are required in binding elements stack.

Element Stack

Custom Binding is constructed using CustomBinding class. The class is defined as below

Constructor of CustomBinding class takes different Binding elements. Binding elements get added in form of element stack described below and shown in the figure above.


 Binding element stack is as below,                                                 

  • At the top is an optional TransactionFlowBindingElement class that allows flowing transactions.
  • Next is an optional ReliableSessionBindingElement class that provides a session and ordering mechanisms as defined in the WS-Reliable Messaging specification?
  • Next is an optional SecurityBindingElement class that provides security features such as authorization and authentication.
  • Next is an optional CompositeDuplexBindingElement class that provides the ability to have two way duplex communications with a transport protocol that does not support duplex communication natively, such as HTTP.
  • Next is an optional OneWayBindingElement class that provides one-way communication.
  • Next is an optional stream security binding element which can be one of the following.
    • SslStreamSecurityBindingElement
    • WindowsStreamSecurityBindingElement


  • Next is a required message encoding binding element. You can use your own message encoder or one of the three message encoding bindings:
    • TextMessageEncodingBindingElement
    • BinaryMessageEncodingBindingElement
    • MtomMessageEncodingBindingElement

At the bottom is a required transport element. You can use your own transport or one of the following transport binding elements Windows Communication Foundation (WCF) provides:

  • TcpTransportBindingElement
  • HttpTransportBindingElement
  • HttpsTransportBindingElement
  • NamedPipeTransportBindingElement
  • PeerTransportBindingElement
  • MsmqTransportBindingElement
  • MsmqIntegrationBindingElement
  • ConnectionOrientedTransportBindingElement

There are two way to create custom binding

  1. Through configuration
  2. Through code

Creating CustomBinding through configuration

In above custom binding, I am using all the basicHttpBinding function but have modified the message format to SOAP11.

In next article I will show you how to create custom binding. Thanks for reading. Happy Coding.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend