This project is read-only.
Project Description
The Generic Host Service provides a simple, reusable, and reliable mechanism for hosting WCF services.


The Generic Host Service provides a declarative service registration mechanism using the application configuration file, support for xcopy deployment of new services, support for hosting multiple WCF Services within a single Service Host instance, logging and tracing through Microsoft Logging Application Blocks, and isolation between executing services through App Domains.

2.1 Declarative Service Registration

To register a new WCF service

1.) Copy the dll that implements the service as well as any supporting dll's to the directory where the service host is installed.
2.) Add a new service entry to the services node of the hostConfiguration section.
* the name attribute is the name under which you would like the service to be hosted. It will replace the {1} parameter in the hostConfiguration endpoint attribute.
* the assemblyqualifiedname attribute contains the fully qualified assembly name of the binary that implements the sevice.
* the endpoint attribute overrides the the default endpoint provided by the hostConfiguation endpoint attribute.
* if you leave the endpoint attribute blank you must configure the endpoint in the bindings.
Note: The endpoint attribute is to allow you to get a service implementation up and running quickly using basicHttpBinding,
you can still choose to define a different endpoint scheme (net.tcp...etc) or define any endpoint you want for your service in
the service binding configuration.
* the filepath attribute is used to specify a different configuration file from the current one for your service to use.
* the enabled attribute allows you to enable or disable the service. The service will not start if the Generic Host is restarted when enabled is set to false
3.) Add the WCF configuration sections as you normally would to configure your endpoint. This is to be done in the current configuration file unless you have specified a new one in the filepath attribute of your service.
4.) Start the Generic Host service

<hostConfiguration endpoint="http://{0}:1400/{1}" hostController="Services.WCF.Hosting.HostController, Services.WCF" subscriber="Services.WCF.Hosting.Monitor, Services.WCF.Hosting">
<services>
<service name="Host" assemblyqualifiedname="Services.WCF.Hosting.HostController, Services.WCF" endpoint="http://{0}:1400/{1}" filepath="" enabled="true"></service>
</services>
</hostConfiguration>


2.2 Service isolation

In addition to these features the Generic Service Host provides native and configurable tracing and logging services by leveraging the Microsoft Logging Application Blocks. It also provides a native WCF service for managing the WCF Services that are executing within its hosting environment. Through the IHostController contract administrative clients can Start, Stop, Recycle, and Enumerate WCF Services.


2.3 IHostController

Based on the configuration above the http://localhost:1400/Host endpoint will expose the IHostController interface detailed below. This interface acts as a Service Manager for the services hosted in the Generic Host Service allowing you to Start, Stop, Restart, and Enumerate services. The HostController also allows you to "hot swap" services. A dll that implements a service can be replaced even while the service is still running. A call to Restart for the instance of that service will then unload the old instance and load the new one.

ServiceContract()
public interface IHostController
{
[OperationContract]
void Start(string Name);

[OperationContract]
void Stop(string Name);

[OperationContract]
void ReStart(string Name);

[OperationContract]
HostControllerEntry[] EnumerateServices();
}

Last edited Apr 24, 2014 at 10:07 AM by ekeratbellsouth, version 12