Retrieving Search Service Status

The search-service-status-xml function (SearchServiceStatusXml in the SOAP API) enables you to retrieve status information in XML format from the Watson Explorer Engine Search Service. Retrieving status information in XML format provides richer information about the actual status of the Search Service than functions that simply return a status code indicating success or failure.

The following code example shows how to retrieve this status information in C#, using the SOAP API:

    SearchServiceStatusXml sssxml = new SearchServiceStatusXml();
    XmlElement stat = port.SearchServiceStatusXml(sssxml);
    XmlNodeList notRunning = stat.SelectNodes("@not-running");
    XmlNodeList serviceStatus = stat.SelectNodes("service-status");
    
    Debug.Assert(notRunning == null || notRunning.Count == 0);
    Debug.Assert(serviceStatus != null);
    Debug.Assert(serviceStatus.Item(0).SelectNodes("@started") != null);

After creating an object to hold the data that is being returned, this function retrieves the status information from the Watson Explorer Engine service, and checks both an XML attributes node that determines whether the Search Service is running, and a specific XML node that provides general status information. The Assert statements in this code example are not intended as suggestions for production code, but rather provide a generic way to indicate how you can test for and conditionally react to specific combinations of return values:

  1. The first of these checks whether the Search Service is running.
  2. The second of these checks whether a status value was returned in the XML data.
  3. The third of these checks whether the XML data shows that the Search Service has been started and is therefore running.