Retrieve a host service instance ID
You can retrieve a host service instance ID for a 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 that you want to find
-
Create an integer to store the host service instance ID.
int hostServiceInstanceID;
-
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 host service instance that you want to retrieve the ID for
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()))
{
hostServiceInstanceID = serviceInstanceResult.serviceInstances[j].serviceId;
break;
}
}
}
Was this information helpful? Send us your comments.