Retrieve a core service instance object
You can retrieve a core service instance for any 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
DispatcherCoreServiceInstance object
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
-
Create a DispatcherCoreServiceInstance
object to store the core service instance.
DispatcherCoreServiceInstance coreServiceInstance;
-
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);
-
Check the result for errors and handle any errors.
if (result.findServiceInstancesByServiceReturnStatus.code != FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS)
{
// handle any errors
}
- Loop through the result until you find the core service instance object that you want to find.
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];
}
}
}
Was this information helpful? Send us your comments.