uCosminexus Service Platform, Basic Development Guide

[Contents][Glossary][Index][Back][Next]

8.7.6 Acquiring Error Information

If an error occurs at the request-destination service component, the HCSC server, or the SOAP engine, acquire the error information and take corrective action according to the information.

For details about how to send an error, see the contents of a user-defined reception in the troubleshooting during the execution of a Web Service (SOAP Communication), in the manual Cosminexus Service Platform System Setup and Operation Guide.

Organization of this subsection
(1) Service requester-side installation example

(1) Service requester-side installation example

The error acquisition method differs depending on the type of SOAP Communication Infrastructure.

(a) When the SOAP Communication Infrastructure provided by Cosminexus is used

How to acquire SOAPFault from a service component
Catch an exception object used for the error information defined in the WSDL and acquire the SOAPFault error information. The format of SOAPFault is the Fault format (Fault format on the service component machine) defined in WSDL.
To acquire SOAPFault from a service component, you need to implement the following at the service requester-side:
 
{
    try {
        ...
      // Invoke Web Services
        ...
    } catch (xxxxxxxxxxException e) {
        ...
    } catch (C4Fault e) {
        ...
    }
}
 

How to acquire an exception that occurred in the HCSC server
Catch the C4Fault object provided in the SOAP Communication Infrastructure of Cosminexus, and acquire the error information.
The process flow at the service requester machine is as follows:
  1. Catch with either C4Fault or RuntimeException.
  2. Extract Element[]with the getFaultDetails() method from C4Fault, and acquire NodeList for each array with the getChildNodes() method.
  3. Extract Node from NodeList, and then use the getTextContent() method to extract the error information for each Node.
An example of implementation at the service requester side when acquiring an exception that occurred in the HCSC server, is described below:
  
{
    try {
        ...
    } catch (xxxxxxxxxxException e) {
        ...
    } catch (C4Fault e) {
      // Acquire Fault information from C4Fault
      System.out.println("C4Fault Message          = " + e.getMessage());
      System.out.println("C4Fault FaultCode        = " + e.getFaultCode());
      System.out.println("C4Fault FaultActor       = " + e.getFaultActor());
      System.out.println("C4Fault FaultString      = " + e.getFaultString());
      // Acquire Detail from C4Fault
      Element ele[] = e.getFaultDetails();
      printElement(ele);
    }
}
 
/**
 * Print Element
 */
  private static void printElement(Element[] ele) {
    int eleNumber = ele.length;
    System.out.println("Element count = " + eleNumber);
    for (int i=0; i<eleNumber; i++) {
      // Acquire NodeList from Element array
      if (ele[i] != null) {
        printNodeList(ele[i].getChildNodes());
      } else {
        System.out.println("Element[" + i + "] = null");
      }
    }
  }
 
/**
 * Print NodeList
 */
  private static void printNodeList(NodeList nodelist) {
    int nodelistcount = nodelist.getLength();
    for (int j=0; j<nodelistcount; j++) {
      Node node1 = nodelist.item(j);
      NodeList nodelist1 = node1.getChildNodes();
      int nodelist1len = nodelist1.getLength();
 
      if (nodelist1len == 0) {
        System.out.println("empty ChildNode");
      } else if(nodelist1len == 1) {
        Node node2 = node1.getFirstChild();
        if(node2 != null) {
          System.out.println("ChildNode[" + j + "] getTextContent = " 
                              + node2.getTextContent());
        } else {
          System.out.println("ChildNode[" + j + "] = null");
        }
      } else {
        printNodeList(nodelist1);
      }
    }
  }
 
The structure of Element[] that is acquired with the getFaultDetails() method is described below:

Table 8-19 Structure of Element[] acquired with the getFaultDetails() method

Name Explanation
errorMessage This is an error message set in the exception that occurred in the HCSC server.
errorCode This is an error code corresponding to the exception that occurred in the HCSC server.
processInstanceID Instance ID information of a business process
Since this information is not set in an exception that occurred in the HCSC server, it becomes null (nil attribute).
(b) When the SOAP Communication Infrastructure provided by Cosminexus is not used

How to acquire SOAPFault from the service component
Catch an exception object used for the error information defined in the WSDL and acquire the SOAPFault error information. The format of SOAPFault is the Fault format (Fault format on the service component machine) defined in WSDL.

How to acquire an exception that occurred in the HCSC server
The acquisition method depends on the SOAP engine that is implemented at the service requester side.