Implement the IEndpointBehavior interface to modify, examine, or extend some aspect of endpoint-wide execution at the application level for either client or service applications.
Use the AddBindingParameters method to pass custom data at runtime to enable bindings to support custom behavior.
Use the ApplyClientBehavior method to modify, examine, or insert extensions to an endpoint in a client application.
Use the ApplyDispatchBehavior method to modify, examine, or insert extensions to endpoint-wide execution in a service application.
Use the Validate method to confirm that a ServiceEndpoint meets specific requirements. This can be used to ensure that an endpoint has a certain configuration setting enabled, supports a particular feature and other requirements.
IEndpointBehavior objects can make use of any of these methods, but often only one is important; in such cases, the unused methods can return, performing no action.
Note: |
|---|
All of the IEndpointBehavior methods pass a ServiceEndpoint object as a parameter. This parameter is for examination only; if you modify the ServiceEndpoint object the execution behavior is undefined. |
IEndpointBehavior objects are typically used to access the various properties of the System.ServiceModel.Dispatcher..::.DispatchRuntime, System.ServiceModel.Dispatcher..::.DispatchOperation, System.ServiceModel.Dispatcher..::.EndpointDispatcher, and System.ServiceModel.Dispatcher..::.ChannelDispatcher objects in a service application and the System.ServiceModel.Dispatcher..::.ClientRuntime and System.ServiceModel.Dispatcher..::.ClientOperation in a client application. In addition, you can access the properties of duplex clients and services using the ClientRuntime..::.CallbackDispatchRuntime and DispatchRuntime..::.CallbackClientRuntime properties, respectively.
For a description of the various properties and customizations available, see Extending ServiceHost and the Dispatcher.
Once a customization has been decided upon (and the customization interface implemented if necessary) and the IEndpointBehavior has been decided is the appropriate scope of customization, the customization must be inserted into the Windows Communication Foundation (WCF) runtime by implementing IEndpointBehavior and adding the endpoint behavior to the runtime.
There are two ways to add the behavior to the runtime:
Programmatically add the custom endpoint behavior to the Behaviors property prior to the opening of the service host (in a service application) or the channel factory (in a client application).
Configure the behavior using an application configuration file. For details, see <behaviorExtensions>.
To perform the service customization task for which it is intended, the IEndpointBehavior object must be added to the ServiceEndpoint..::.Behaviors property prior to the construction of the service runtime, which occurs when ICommunicationObject..::.Open method is called on System.ServiceModel..::.ServiceHost. To perform a client customization task, the IEndpointBehavior object must be added to the ServiceEndpoint..::.Behaviors property before calling the ChannelFactory<(Of <(TChannel>)>)..::.CreateChannel method or the ICommunicationObject..::.Open method on ChannelFactory<(Of <(TChannel>)>).