Kavin's SOA Blog

March 10, 2009

Playing around with Oracle ESB 10.1.3.3.x Client API

  • Overview

The ESB client API is a thin REST based wrapper that allows you to execute any operation on the ESB DT server that can be performed in the ESB Control console.

  • Classes
    • ConsoleClient – Provides the interface to interact with the ESB Console Backend to perform actions on metadata and instance
    • ConsoleClientFactory – Provides the ConsoleClient object
  • Libraries
    • oraesb_patch.jar
    • xmlparserv2.jar – you should be able to get this file from <SOA_HOME>\lib\xmlparserv2.jar
  • Flow

In a nutshell, this is a three step process

  • Connect to ESB DT i.e. get handle of ConsoleClient object using ConsoleClientFactory
  • Populate hashtable with required parameters
  • Make a call to perform operation in client object with operation name and properties (as hashtable)

Once you received a ConsoleClient handle you can perform as many operations as you want to, no need to get this one separately for every operation.

  • Connecting to ESB DT

    private void connectToESBDT(String host, int port, String username, String password) throws Exception {
    try {
    System.out.println (“connecting to esb”);
    client = ConsoleClientFactory.getConsoleClient(host, port, username, password);
    } catch (ClientException e) {
    System.out.println (“error connecting to esb”, e);
    throw new Exception(e);
    }

  • Executing any request – To execute any operation, there is only one method available i.e. perform. This method takes two parameters operation name and hash table which contains parameters associated with that request.

    private String performOperation(String operation, HashMap<String, String> requestProps) throws Exception {
    String output = client.perform(operation, requestProps);
    System.out.println(operation + ” response: \n ” + output);
    return output;
    }

  • Update DVM – To update a DVM you need to pass two values name which is the name of DVM and map which is a DVM XML. Please remember that DVMs are stored as XML in ESB-DT and whatever XML you are passing as a parameter, that XML will be persisted as DVM definition in XML.

    HashMap<String, String> requestProps = new HashMap<String, String>();
    requestProps.put(“name”, dvmName);
    requestProps.put(“map”, URLEncoder.encode(dvmData, “UTF-8”));
    System.out.println (“updating dvm – ” + dvmName);
    performOperation(“UpdateDVM”, requestProps);

  • Update Service Status to ENABLED or DISABLED – TO update service status you need service GUID, which you can get it by opening respective ESBSVC file in a notepad and check for “guid” attribute of “service” element. You can only pass ENABLED or DISABLED as the values for status parameter.

    HashMap<String, String> requestProps = new HashMap<String, String>();
    requestProps.put(“service”, URLEncoder.encode(serviceGUID, “UTF-8”));
    requestProps.put(“status”, status);
    performOperation(“UpdateServiceStatus”, requestProps);

  • Get list of Instances matching a filter criteria

    Sample filter condition: <instanceFilter timeZone=”GMT+05:30″><startTime>86400000</startTime></instanceFilter> returns all the instances created in “Last 1 day”

    HashMap<String, String> requestProps = new HashMap<String, String>();
    requestProps.put(“filter”, URLEncoder.encode(filter, “UTF-8”));
    System.out.println (“querying failed instances from esb”);
    return performOperation(“GetInstances “, requestProps);

  • Get list of failed Instances matching a filter criteria.

    Sample filter condition: <failedInstanceFilter includeMoreDetails=”true”><status>RetryableError</status></failedInstanceFilter> returns all the error instances (retryable or non-retryable)

    HashMap<String, String> requestProps = new HashMap<String, String>();
    requestProps.put(“filter”, URLEncoder.encode(filter, “UTF-8”));
    System.out.println (“querying failed instances from esb”);
    return performOperation(“GetFailedInstances”, requestProps);

  • Resubmit Instances by IDs – To resubmit a given instance which can be uniquely identified by parameters flowid and systemid. You can use Get Failed Instances (mentioned above) to get those values. There is also another operation to resubmit in bulk.

    HashMap<String, String> requestProps = new HashMap<String, String>();
    requestProps.put(“flowId”, URLEncoder.encode(flowId, “UTF-8”));
    requestProps.put(“systemId”, URLEncoder.encode(systemId, “UTF-8”));
    System.out.println (“Resubmitted InstanceId: ” + flowId + ” with SystemId ” + systemId);
    performOperation(“ResubmitInstanceById”, requestProps);

Blog at WordPress.com.