Retrieve a core service instance ID

You can retrieve a core 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 core service instance ID.
Before you begin: Retrieve the following variables:
  • serviceID integer for the service that you want to find the core service instance ID of
  • instanceName string for the name of the core service instance that you want to find the ID for
  1. Create an integer to store the core service instance ID.
    int coreServiceInstanceID;
  2. 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);
  3. Check the result for errors and handle any errors.
    if (result.findServiceInstancesByServiceReturnStatus.code != FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS) 
    {    
    	    // handle any errors
    } 
  4. Loop through the result until you find the core 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(DispatcherCoreServiceInstance)))
        {
            if (serviceInstanceResult.serviceInstances[j].name.ToUpper().Equals(instanceName.ToUpper()))
            {
                return serviceInstanceResult.serviceInstances[j].serviceId;
            }
        }
    }

Was this information helpful? Send us your comments.