IServiceBehavior::Validate Method (ServiceDescription^, ServiceHostBase^)
Provides the ability to inspect the service host and the service description to confirm that the service can run successfully.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Parameters
- serviceDescription
-
Type:
System.ServiceModel.Description::ServiceDescription^
The service description.
- serviceHostBase
-
Type:
System.ServiceModel::ServiceHostBase^
The service host that is currently being constructed.
Use the Validate method to confirm whether the current service can execute properly according to your scenario.
Note |
|---|
All of the IServiceBehavior methods pass System.ServiceModel.Description::ServiceDescription and System.ServiceModel::ServiceHostBase objects as a parameters. The ServiceDescription parameter is for examination and insertion of customizations only; if you otherwise modify these objects the execution behavior is undefined. |
The following code example shows the use of a service behavior specified in a configuration file to insert a custom error handler in a service application. In this example, the error handler catches all exceptions and converts them into a custom GreetingFault SOAP fault that is then returned to the client.
The following IServiceBehavior implementation adds no binding parameter objects, adds the custom System.ServiceModel.Dispatcher::IErrorHandler object to each ChannelDispatcher::ErrorHandlers property, and validates that each operation of the service to which the service behavior is applied and has a System.ServiceModel::FaultContractAttribute of type GreetingFault.
In this example, the behavior class also implements System.ServiceModel.Configuration::BehaviorExtensionElement, which enables the service behavior to be inserted by using it in an application configuration file, as the following code example demonstrates.
Available since 3.0
