uCosminexus Service Platform, Basic Development Guide

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

8.7.7 Procedure for creating a service requester (User-defined Reception (Web Service)) (JAX-WS engine)

A service requester that uses JAX-WS engine for communication can be created as the service requester for sending requests to a user-defined reception (Web Services). The service requester that uses the JAX-WS engine for communication sends request messages to the user-defined reception (Web Services) using SOAP (document-literal type).

The following figure shows the relationship between a service requester that uses the JAX-WS engine for communication and an HCSC server:

Figure 8-34 Relationship between a service requester that uses the JAX-WS engine for communication and an HCSC server (User-defined reception (Web Services))

[Figure]

The procedure for creating a service requester that uses the JAX-WS engine for communication is as follows:

Figure 8-35 Procedure for creating a service requester that uses the JAX-WS engine for communication (User-defined reception (Web Services))

[Figure]

The tasks in the individual steps are described below.

Organization of this subsection
(1) WSDL editing
(2) Service class creation
(3) Object generation
(4) Response message acquisition
(5) Error information acquisition

(1) WSDL editing

The WSDL editing method is the same as that used for creating an ordinary service requester in SOAP communication infrastructure.

For details about how to edit WSDL, see 8.7.2 Editing a WSDL.

(2) Service class creation

Create a service class from the edited WSDL. To create a service class, you use the cjwsimport command provided by Cosminexus as a development support command.

A command input example is shown below:

 
cjwsimport -s source-file-output-destination-directory -d compiled-class-file-output-destination-directory WSDL-file
 

For details about options of the cjwsimport command, see the manual Cosminexus Application Server Web Service Development Guide.

If the WSDL file edited in 10.6.7(1) WSDL editing is saved at a location different from the current directory in which the cjwsimport command is executed, also specify the directory.

If you execute this command, the directories and files will be created in the output destination directory of the specified source file based on the contents described in the WSDL.

Note
For a service requester that uses JAX-WS engine for communication, the WSDL will be read during the execution of the program. When the default constructor of the service class is used, the WSDL in the WSDL path (directory that stores the WSDL file acquired in 10.6.7(1) WSDL acquisition for creating the service class) specified with the cjwsimport command will be read. Therefore, after executing the cjwsimport command, do not move the WSDL file so that the configuration position of the WSDL file based on the service class does not destroy the relative relationship. For changing the configuration position of the WSDL referenced during the execution of the service requester from the WSDL path specified with the cjwsimport command, use a constructor for which the URL can be specified.

(3) Object generation

To invoke a method of user-defined reception (Web Services), use the created service class and generate proxy class objects.

The following describes the procedure for creating an object of the proxy class for invoking user-defined reception (Web Services) on the basis of the created service class:

  1. Create the service class.
  2. Create the proxy class corresponding to wsdl:portType.
  3. Use objects of the created proxy class and invoke service methods.

By invoking a method of the generated object, a request for service component execution is sent to the user-defined reception. Within the objects of a service class, request messages (SOAP messages) are automatically generated in the format defined in the WSDL.

(4) Response message acquisition

The response message acquisition method is the same as that used for creating an ordinary service requester in SOAP communication infrastructure.

For details about response message acquisition, see 8.7.5 Acquiring Response Messages.

(5) Error information acquisition

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.

How to acquire SOAPFault from a service component
For a service requester that uses the JAX-WS engine for communication, the exception in which the information is wrapped will be caught. Therefore, to acquire a user-defined reception, the fault information save class must be acquired using the getFaultInfo() method.

How to acquire an exception that occurred in the HCSC server
Acquire the error information by catching the javax.xml.ws.soap.SOAPFaultException object.
The process flow at the service requester machine is as follows:
  1. Catch with SOAPFaultException.
  2. Extract SOAPFault from SOAPFaultException using the getFault() method.
  3. From SOAPFault, extract the information about the SOAP Fault.
An example of implementation at the service requester side when acquiring an exception that occurred in the HCSC server, is described below:
 
/**
 * Sample Program
 */
{
    try {
         ...
    } catch (xxxxxxxxxxException_Exception e) {
       // When the SOAP fault defined in WSDL is returned back
      xxxxxxxxxxException faultInfo = e.getFaultInfo();
         ...
    } catch (SOAPFaultException e) {
       // When an error occurs in the HCSC server
      SOAPFault soapFault = e.getFault();
      if(soapFault != null) {
         // Output the information about SOAP fault
         System.err.println("faultCode=" + soapFault.getFaultCode());
         System.err.println("faultActor=" + soapFault.getFaultActor());
         System.err.println("faultString=" + soapFault.getFaultString());
         Detail detail = soapFault.getDetail();
         if(detail != null) {
           for(Iterator ite = detail.getDetailEntries(); ite.hasNext(); ) {
             printDetail((Element)ite.next());
          }
        }
      }
    }
}
The structure of Element[] acquired with the getDetail() method is as shown in the following table:

Table 8-20 Structure of Element[] acquired with the getDetail() method

Name Content
errorMessage This is the error message set up in the exception.
errorCode This is the error code corresponding to the error message set up in an exception.
processInstanceID This is the process instance ID of the business process. Because the process instance ID is not set up for an error detected in the messaging infrastructure, this will become null (nil attribute). This is applicable for an error occurring in the business process.