BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Using BEA Jolt with BEA WebLogic Server   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents

 


Receiving Results from a Service

The ServletSessionPool.call() method returns a ServletResult object that contains the results from the Tuxedo service. If the service call fails, an exception is thrown. You should always attempt to catch exceptions and handle them appropriately. Refer to "Appendix A, BEA Jolt Exceptions" in Using BEA Jolt for details about the possible exceptions that can occur.

The following example retrieves a ServletResult object using the ServletSessionPool.call() method in an HTTP servlet:

  ServletResult sResult = ssPool.call("service_name", request);

where ssPool is a ServletSessionPool, and request is an HttpServletRequest.

The ServletSessionPool.call() method returns a Result object that you must cast as a ServletResult object. The ServletResult object provides extra methods for retrieving data as Java Strings.

Provided the call was successful, the individual parameters can be retrieved from the Result or ServletResult object using various forms of the getValue() method.

Using the Result.getValue() Method

The data is retrieved from a ServletResult by providing a key that corresponds to the parameter names of the Tuxedo service, as defined in the Jolt Repository. You supply the key to the appropriate getValue() method, which returns the corresponding value object.

The Result.getValue() method also expects a default value object; this is returned if the key lookup fails. It is your responsibility to cast the returned object to the appropriate type, as defined by the Tuxedo service. For example, this line of code:

  Integer answer = (Integer) resultSet.getValue("Age", null);

sets the integer answer to the returned value in the ServletResult identified by the key "Age", or returns null if this key does not exist in the ServletResult. Refer to the table in Converting Java Data Types to Tuxedo Data Types for the Java equivalents of the Tuxedo types.

It is possible to have an array of values associated with a key. In this case, the simple getValue() method returns the first element of an array in this instance. Use this method signature in that case:

  public Object getValue(String name, int index, Object defVal)

to reference a particular indexed element in an array value.

Using the ServletResult.getStringValue() Method

ServletResult extends Result, and provides the additional methods:

  public String getStringValue(String name,
                               int index,
                               String defVal)
                             
  public String getStringValue(String name,
                               String defVal)

These methods behave like the getValue() methods of the Result class, except that they always return a Java string equivalent of the value object expected. The CARRAY is converted into a string of two digit hexadecimal byte values as described in Converting Java Data Types to Tuxedo Data Types.

 

back to top previous page next page