Retrieve a host service instance object
You can retrieve a host service instance for any component that can be configured to support high availability. Components that cannot be configured to support high availability have only a service instance.
The following code sample retrieves a
Dispatcher host service instance.
Before you begin: Retrieve the following variables:
- serviceID integer for the service ID that you want to find
a host service instance of
- instanceName string for the name of the host service instance you want to find
-
Create a DispatcherHostServiceInstance
object to store the host service instance.
DispatcherHostServiceInstance hostServiceInstance;
-
Invoke findServiceInstancesByService().
FindServiceInstancesByService request = new findServiceInstancesByService();
request.serviceId = serviceID;
request.locale = locale;
request.includeStatus = false;
request.includeExtendedData=true;
request.loadServiceConsumerRelationships=false;
request.loadServiceConsumerRelationships=false;
FindServiceInstancesByServiceResponse response = coreWebService.findServiceInstancesByService(request);
-
Check the result for errors and handle any errors.
if (result.findServiceInstancesByServiceReturnStatus.code != FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS)
{
// handle any errors
}
- Loop through the result until you find the dispatcher host service instance object you want to find.
for (int j = 0; j < serviceInstanceResult.serviceInstances.Length; j++)
{
if (serviceInstanceResult.serviceInstances[j].GetType().Equals(typeof(DispatcherHostServiceInstance)))
{
if (serviceInstanceResult.serviceInstances[j].name.ToUpper().Equals(instanceName.ToUpper()))
{
return serviceInstanceResult.serviceInstances[j];
}
}
}
Was this information helpful? Send us your comments.