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
  1. Create an integer to store the host service instance ID.
    int hostServiceInstanceID;
  2. Invoke findServiceInstancesByService().
    boolean includeStatus=false;
    boolean includeExtendedData=true;
    boolean loadServiceConsumerRelationships=false;
    boolean loadServiceProducerRelationships=false;
    FindServiceInstancesByServiceResult result=coreWebService.findServiceInstancesByService(serviceID, locale, includeStatus, includeExtendedData, loadServiceConsumerRelationships, loadServiceProducerRelationships);  
  3. Check the result for errors and handle any errors.
    if (result.getFindServiceInstancesByServiceReturnStatus().getCode()!= FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS) 
    	    // handle any errors
  4. Loop through the result until you find the host service instance that you want to retrieve the ID for
    List<ServiceInstanceType> serviceInstances = result.getServiceInstances();
    for (ServiceInstanceType itr:serviceInstances) 
         if (itr2 instanceof DispatcherHostServiceInstance) 
            if (itr2.getName().equalsIgnoreCase(instanceName)) 
                hostServiceInstanceID =itr2.getServiceId();

Was this information helpful? Send us your comments.