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().
    FindServices request = new findServices();
    request.locale = locale;
    request.includeSettings = true;
    FindServicesResponse response = coreWebService.findServices(request);
    FindServicesResult result = response.returnValue;
  3. Check the result for errors and handle any errors.
    if (result.findServicesReturnStatus.code != 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 (int i = 0; i < servicesResult.services.Length; i++)
    {
        if (result.services[i].GetType().Equals(typeof(DispatcherService)))
        {
            service = servicesResult.services[j].serviceId;
            break;
        }
    }
Previous topic: Retrieve a service object

Was this information helpful? Send us your comments.