uCosminexus Service Platform, Basic Development Guide

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

8.2.4 Generating Objects

In order to invoke the method of the synchronous reception (Web Services), use the stubs created in (1) to generate objects.

Organization of this subsection
(1) Stubs to be used
(2) Object generation procedure

(1) Stubs to be used

Use the following two classes of stubs to generate objects:

CSCMsgSyncServiceDeliveryWSImplServiceLocator.java class
This class is used to reference and set up the connection destination (endpoint) information to a service component. This class provides the methods listed in the following table.

Table 8-2 CSCMsgSyncServiceDeliveryWSImplServiceLocator.java class methods

Method name Function explanation
getCSCMsgSyncServiceDeliveryWSImplAddress() Returns the connection destination information to the service component.

Return value:
java.lang.String
getCSCMsgSyncServiceDeliveryWSImpl() Returns the object pointer of the interface class to the service class.

Return value:
Interface class object (CSCMsgSyncServiceDeliveryWSImpl object)
getCSCMsgSyncServiceDeliveryWSImpl(java.net.URL portAddress) Uses the specified connection destination information to the service component to return the object pointer to the service class.

Return value:
Interface class object (CSCMsgSyncServiceDeliveryWSImpl object)

CSCMsgSyncServiceDeliveryWSImpl.java class
Describes a list of methods that can be used as a service class. Use this class to utilize the SOAP service.

(2) Object generation procedure

To generate an object for invoking a synchronous reception (Web Services) method:

  1. Create a CSCMsgSyncServiceDeliveryWSImplServiceLocator class object, which is the service component's interface class.
    Example:
     
    CSCMsgSyncServiceDeliveryWSImplServiceLocator locator
                 = new CSCMsgSyncServiceDeliveryWSImplServiceLocator();
     
  2. Using the service component's interface class object, create a CSCMsgSyncServiceDeliveryWSImpl.java class object, which is the service requester's interface class.
    The instance of the service requester's interface class created or acquired cannot be shared by multiple threads.
    Example:
     
    CSCMsgSyncServiceDeliveryWSImpl ws = null;
    try {
          ws = locator.getCSCMsgSyncServiceDeliveryWSImpl();
    }catch (ServiceException e) {
                  e.printStackTrace();
                  return;
    }
     
     
    The connection destination to the service component is the location attribute, which is an address child element of the Service element inside the WSDL definition. To acquire the connection destination to the service component within the service requester's program, use the following coding:
    Example:
     
    String url = locator.getCSCMsgSyncServiceDeliveryWSImplAddress();
     
     
    To change the connection destination to the service component within the service requester's program, use the following coding:
    Example:
     
    java.net.URL endpoint
     = new java.net.URL("http://hostname:80/context-root
                      /services/CSCMsgSyncServiceDeliveryWSImpl");
    CSCMsgSyncServiceDeliveryWSImpl locator
     = locator.getCSCMsgSyncServiceDeliveryWSImpl(endpoint);
     
  3. Using the created CSCMsgSyncServiceDeliveryWSImpl.java class object, invoke a method of the synchronous reception (Web Services).
    Example: When the request message is in XML
     
    String result = ws.invokeXML(               // method invocation
                           serviceName,         // service name
                           clientID,            // client correlation ID
                           requestFormatID,     // request format ID
                           responseFormatID,    // response format ID
                           operationName,       // operation name
                           userData);           // user message
     
    Example: When the request message is binary
     
    byte[] resultBinary = ws.invokeBinary(      // method invocation
                              serviceName,      // service name
                              clientID,         // client correlation ID
                              requestFormatID,  // request format ID
                              responseFormatID, // response format ID
                              operationName,    // operation name
                              userDataBinary.length,  // user message length
                              userDataBinary);  // user message
     
    Note
    A binary request message can be sent only when the message format used on the service component side is binary.