Compartir a través de


Binding Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Contains the binding elements that specify the protocols, transports, and message encoders used for communication between clients and services.

Inheritance Hierarchy

System.Object
  System.ServiceModel.Channels.Binding
    System.ServiceModel.BasicHttpBinding
    System.ServiceModel.Channels.CustomBinding
    System.ServiceModel.PollingDuplexHttpBinding

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public MustInherit Class Binding _
    Implements IDefaultCommunicationTimeouts
public abstract class Binding : IDefaultCommunicationTimeouts

The Binding type exposes the following members.

Constructors

  Name Description
Protected methodSupported by Silverlight for Windows Phone Binding() Initializes a new instance of the Binding class with a default name and namespace.
Protected methodSupported by Silverlight for Windows Phone Binding(String, String) Initializes a new instance of the Binding class from a specified binding of the service.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone CloseTimeout Gets or sets the interval of time provided for a connection to close before the transport raises an exception.
Public propertySupported by Silverlight for Windows Phone MessageVersion Gets the message version used by clients and services configured with the binding.
Public propertySupported by Silverlight for Windows Phone Name Gets or sets the name of the binding.
Public propertySupported by Silverlight for Windows Phone Namespace Gets or sets the XML namespace of the binding.
Public propertySupported by Silverlight for Windows Phone OpenTimeout Gets or sets the interval of time provided for a connection to open before the transport raises an exception.
Public propertySupported by Silverlight for Windows Phone ReceiveTimeout Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped.
Public propertySupported by Silverlight for Windows Phone Scheme When implemented in a derived class, sets the URI scheme that specifies the transport used by the channel factories that are built by the bindings.
Public propertySupported by Silverlight for Windows Phone SendTimeout Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone BuildChannelFactory<TChannel>(BindingParameterCollection) Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by a collection of binding parameters.
Public methodSupported by Silverlight for Windows Phone BuildChannelFactory<TChannel>(array<Object[]) Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by an object array.
Public methodSupported by Silverlight for Windows Phone CanBuildChannelFactory<TChannel>(BindingParameterCollection) Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the collection of binding parameters specified.
Public methodSupported by Silverlight for Windows Phone CanBuildChannelFactory<TChannel>(array<Object[]) Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the requirements specified by an object array.
Public methodSupported by Silverlight for Windows Phone CreateBindingElements When overridden in a derived class, creates a collection that contains the binding elements that are part of the current binding.
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetProperty<T> Returns a typed object requested, if present, from the appropriate layer in the binding stack.
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

Represents a collection of binding elements, each of which describes an aspect of how an endpoint communicates with other endpoints and that are built, consistently, into a channel factory on the client. A binding contains a collection of binding elements that correspond to protocol channels and transport channels, which also specify message encoders. There can be any number of binding elements for protocol channels but one and only one binding element for each the transport and message encoder. The transport and encoding binding elements are required. Because an encoding is required for each binding, if an encoding is not specified, Silverlight adds a default encoding for you. The default is Text/XML for the HTTP transport.

The following table summarizes the required layers.

Layer

Options

Required

Encoding

Text, Binary, MTOM, Custom

Yes

Transport

HTTP, Custom

Yes

Each binding element provides the specification for building a channel factory for a Silverlight client. When the channel factory stack is constructed, for example, there is one channel factory in the stack for each binding element in the binding. Consistency on the client and service is critical for establishing the channel-based connection between these endpoints. Each factory on the client processes the sending and accepting of the corresponding channels in the channel stack, and these channels, once constructed, can send and receive the messages used to communicate with a service.

Each instance of a Binding has a Name and Namespace that together uniquely identify it in the metadata of the service. If no name or namespace is specified, Silverlight adds a default values for you. The default Name is nulla null reference (Nothing in Visual Basic) and the default Namespace is http://tempuri.org/. Note that this user name for the binding is distinct from the specification of the protocol name, which is specified by the Scheme property. If you want to add more HTTP bindings, for example, you can name them whatever you want and set all of their schemes to "http". There is no inherent application or machine dispatch based on the Scheme. So you avoid the common problem of being unable to register additional handlers for well-known protocols. You can also easily work with multiple versions of a binding side-by-side by giving each version a different name.

The Binding class implements the IDefaultCommunicationTimeouts interface to mitigate Denial of Service (DOS) attacks that rely on tying up resources for extended intervals of time. The implementation specifies the communication time-out values for opening and closing connections and for the reading and writing operations associated with receiving and sending messages. The properties used to get and set these time-outs and their default value operations are summarized in the following table.

Timeout Property

Default Value

OpenTimeout

1 minute

CloseTimeout

1 minute

SendTimeout

1 minute

ReceiveTimeout

10 minutes

When you create a binding by inheriting from Binding, you must override CreateBindingElements.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.