Retrieve a service object

To retrieve a Service object, you can use the findServices() method. The following code sample retrieves a service object of the type DispatcherService.
  1. Create the object that you want to store the service object as.
    DispatcherService service;
  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. 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 <; i++)
        if ([i].GetType().Equals(typeof(DispatcherService)))
            service =[j];

Was this information helpful? Send us your comments.