Retrieve a service ID

To retrieve a service ID, you can use the findServices() method. The following code sample retrieves the ID of the service of the type DispatcherService.
  1. Create the object that you want to store the service object as.
    int serviceID;
  2. Invoke findServices().
    boolean includeSettings = true;
    FindServicesResult servicesResult = coreWebService.findServices(locale, includeSettings);
  3. Check the result for errors and handle any errors.
    if (servicesResult.getFindServicesReturnStatus().getCode()!= FindServicesReturnStatusEnumType.SUCCESS) 
        // handle any errors
  4. Loop through the result to find the DispatcherService ID. The following code sample assumes that there is only one instance of the service you want to retrieve. If your organization is configured for high availability with multiple instances of the service you want to retrieve, you should check each instance.
    for (ServiceType itr:servicesResult.getServices()) 
        if (itr instanceof DispatcherService) {
            serviceID = itr.getServiceId();
Previous topic: Retrieve a service object

Was this information helpful? Send us your comments.