Custom Bindings

You can use the CustomBinding class when one of the system-provided bindings does not meet the requirements of your service. All bindings are constructed from an ordered set of binding elements. Custom bindings can be built from a set of system-provided binding elements or can include user-defined custom binding elements. You can use custom binding elements, for example, to enable the use of new transports or encoders at a service endpoint. For working examples, see Custom Binding Samples. For more information, see <customBinding>.

Construction of a Custom Binding

A custom binding is constructed using the CustomBinding constructor from a collection of binding elements that are "stacked" in a specific order:

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:

The following table summarizes the options for each layer.

Layer Options Required
Transactions TransactionFlowBindingElement No
Reliability ReliableSessionBindingElement No
Security SecurityBindingElement No
Encoding Text, binary, Message Transmission Optimization Mechanism (MTOM), custom Yes
Transport TCP, HTTP, HTTPS, named pipes (also known as IPC), Peer-to-Peer (P2P), Message Queuing (also known as MSMQ), Custom Yes

In addition, you can define your own binding elements and insert them between any of the preceding defined layers.

See also