BinaryMessageEncodingBindingElement Class


The binding element that specifies the .NET Binary Format for XML used to encode messages.

public ref class BinaryMessageEncodingBindingElement sealed : System::ServiceModel::Channels::MessageEncodingBindingElement, System::ServiceModel::Description::IPolicyExportExtension, System::ServiceModel::Description::IWsdlExportExtension
public sealed class BinaryMessageEncodingBindingElement : System.ServiceModel.Channels.MessageEncodingBindingElement, System.ServiceModel.Description.IPolicyExportExtension, System.ServiceModel.Description.IWsdlExportExtension
type BinaryMessageEncodingBindingElement = class
    inherit MessageEncodingBindingElement
    interface IWsdlExportExtension
    interface IPolicyExportExtension
Public NotInheritable Class BinaryMessageEncodingBindingElement
Inherits MessageEncodingBindingElement
Implements IPolicyExportExtension, IWsdlExportExtension


var be = new BinaryMessageEncodingBindingElement();
be.MaxReadPoolSize = 16;
be.MaxSessionSize = 2048;
be.MaxWritePoolSize = 16;
be.MessageVersion = MessageVersion.Default;
XmlDictionaryReaderQuotas quotas = be.ReaderQuotas;

var binding = new CustomBinding();
var bpCol = new BindingParameterCollection();
var context = new BindingContext(binding, bpCol);

var binding2 = new CustomBinding();
var bpCol2 = new BindingParameterCollection();
var context2 = new BindingContext(binding2, bpCol2);

BindingElement bindingElement = be.Clone();
MessageEncoderFactory mef = be.CreateMessageEncoderFactory();
MessageVersion mv = be.GetProperty<MessageVersion>(context);
Dim be As New BinaryMessageEncodingBindingElement()
be.MaxReadPoolSize = 16
be.MaxSessionSize = 2048
be.MaxWritePoolSize = 16
be.MessageVersion = MessageVersion.Default
Dim quotas As XmlDictionaryReaderQuotas = be.ReaderQuotas

Dim binding As New CustomBinding()
Dim bpCol As New BindingParameterCollection()
Dim context As New BindingContext(binding, bpCol)
be.BuildChannelFactory(Of IDuplexChannel)(context)

Dim binding2 As New CustomBinding()
Dim bpCol2 As New BindingParameterCollection()
Dim context2 As New BindingContext(binding2, bpCol2)
be.BuildChannelListener(Of IDuplexChannel)(context2)

be.CanBuildChannelListener(Of IDuplexChannel)(context2)
Dim bindingElement As BindingElement = be.Clone()
Dim mef As MessageEncoderFactory = be.CreateMessageEncoderFactory()
Dim mv As MessageVersion = be.GetProperty(Of MessageVersion)(context)


Encoding is the process of transforming a message into a sequence of bytes. Decoding is the reverse process. Windows Communication Foundation (WCF) includes three types of encoding for SOAP messages: Text, Binary and Message Transmission Optimization Mechanism (MTOM).

BinaryMessageEncodingBindingElement is the binding element that specifies that the .NET Binary Format for XML should be used for encoding messages. It has options to specify the character encoding and the SOAP and WS-Addressing version to be used. Binary encoding is the most efficient but least interoperable of the encoding options.

For more information about the binding element that specifies messages are encoded using a textual representation of XML, see TextMessageEncodingBindingElement.

For more information about the binding element that specifies messages are encoded using the MTOM message encoding, see MtomMessageEncodingBindingElement.

To implement a custom message encoder, use the MessageEncodingBindingElement class.



Initializes a new instance of the BinaryMessageEncodingBindingElement class.



Gets or sets the compression format for the binding element.


Gets or sets the maximum number of XML readers that are allocated to a pool and are ready for use to process incoming messages.


Gets or sets the maximum amount of memory available within a session for optimizing transmission procedures.


Gets or sets the maximum number of XML writers that are allocated to a pool and are ready for use to process outgoing messages.


Gets or sets the SOAP message and WS-Addressing versions that are used or expected.


Gets or sets constraints on the complexity of XML messages that can be processed by endpoints configured with this binding element.



Builds the channel factory stack on the client that creates a specified type of channel for a specified context.


Builds the channel listener on the service that accepts a specified type of channel for a specified context.


Returns a value that indicates whether the binding element can build a channel factory for a specific type of channel.

(Inherited from BindingElement)

Returns a value that indicates whether the current binding can build a listener for a specified type of channel and context.


Creates a new BinaryMessageEncodingBindingElement object initialized from the current one.


Creates a factory for binary message encoders that employ the SOAP and WS-Addressing versions and the character encoding specified by the current encoding binding element.


Determines whether the specified object is equal to the current object.

(Inherited from Object)

Serves as the default hash function.

(Inherited from Object)

Returns a typed object requested, if present, from the appropriate layer in the binding element stack.


Gets the Type of the current instance.

(Inherited from Object)

Creates a shallow copy of the current Object.

(Inherited from Object)

Returns whether the SOAP message structure version should be serialized.


Returns whether the values of constraints placed on the complexity of SOAP message structure should be serialized.


Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

Writes a custom binary message encoding elements into the generated metadata for an endpoint.

IWsdlExportExtension.ExportContract(WsdlExporter, WsdlContractConversionContext)

Writes a custom binary message encoding elements into the generated WSDL for a contract.

IWsdlExportExtension.ExportEndpoint(WsdlExporter, WsdlEndpointConversionContext)

Writes a custom binary message encoding elements into the generated WSDL for an endpoint.

Applies to