Pages

Men

rh

6/09/2012

Creating s Service Host Factory

To create a  service host factory, you implement the Create Service Host method by deriving from the ServiceHostFactory class. This method is responsible for returning a new instance of the custom host class.  You can then create  Servicehost, even though WAS and IIS 7.0 would normally do this for you.

Example:
C#

public CustomServiceHost: ServiceHost
{
 public CustomServiceHost(Type ServiceType, param Uri[]  baseAddress): base(serviceType, baseAddress) {}

protected override void onOpening()
{
base.onOpening();
}

protected override void onClosing()
{
base.onClosing()
}

VB:

Class CustomSeriveHost
          inherits Servicehost
          public Sub New (ByVal serviceType as Type, ParamArray baseAddress as Uri())
                     Mybase.New(ServiceTyp, baseAddress)
          End Sub

          Protected Overloads Overrides Sub  OnOpening()
             Mybase.OnOpening()
          End Sub

          Protected  Overloads Overrides Sub  OnClosing()
             Mybase.OnClosing()
          End Sub

No comments :

Post a Comment