Use a custom binding when one of the system-provided bindings does not meet the requirements of your service. A custom binding could be used, for example, to enable the use of a new transport or a new encoder at a service endpoint.
A custom binding is constructed using one of the CustomBinding from a collection of binding elements that are "stacked" in a specific order:
At the top is an optional TransactionFlowBindingElement that allows flowing transactions.
Next is an optional ReliableSessionBindingElement that provides a session and ordering mechanism as defined in the WS-ReliableMessaging specification. This notion of a session can cross SOAP and transport intermediaries.
Next is an optional security binding element that provides security features like authorization, authentication, protection, and confidentiality. The following security binding elements are provided by Windows Communication Foundation (WCF):
Next are the optional message-patterns specified by binding elements:
CompositeDuplexBindingElement
Next are the optional transport upgrades/helpers binding elements:
Next is a required message encoding binding element. You can use your own transport or use one of the following message encoding bindings:
At the bottom is a required transport element. You can use your own transport or use one of transport binding elements provided by Windows Communication Foundation (WCF):
The following table summarizes the options for each layer.
Layer | Options | Required |
|---|
Transaction Flow | TransactionFlowBindingElement | No |
Reliability | ReliableSessionBindingElement | No |
Security | Symmetric, Asymmetric, Transport-Level | No |
Shape Change | CompositeDuplexBindingElement | No |
Transport Upgrades | SSL stream, Windows stream, Peer Resolver | No |
Encoding | Text, Binary, MTOM, Custom | Yes |
Transport | TCP, Named Pipes, HTTP, HTTPS, flavors of MSMQ, Custom | Yes |
In addition, you can define your own binding elements and insert them between any of the preceding defined layers.
For a discussion on how to use a custom binding to modify a system-provided binding, see How To: Customize a System-Provided Binding.