Updating the SOA Composite for invoking OIM APIs from SOA Composites

To edit the SOA composite in JDeveloper:

  1. In the left pane, click the Projects tab.
  2. Select the ApprovalProcess.bpel file under the DefaultRequestApproval project and open it. This displays the approval workflow.
  3. In the right pane, in the Component Palette, select the Java Embedding task, and drag and drop it after the receiveInput task in the workflow, before the ApprovalTask_1 human task. This creates a new task called Java_Embedding_1. Optionally, you can rename it to Invoke_OIM_API.
  4. Double-click the Invoke_OIM_API Java task. This opens an editor in which you can add the required Java code. Add the Java code as shown in Example 22-1:

    Example 22-1 Embedded Java Source Code

    try {
    System.out.println("Prototype for invoking an OIM API from a SOA Composite");
    String oimUserName = "xelsysadm";
    String oimPassword = "Welcome1";
    String oimURL = "t3://<hostname>:<port>";
    // set the initial context factory
    String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
    // set up the environment for making the OIM API invocation
    java.util.Hashtable env = new java.util.Hashtable();
    env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
    env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, oimURL);
    // get reference to OIMClient and perform login
    oracle.iam.platform.OIMClient client = new oracle.iam.platform.OIMClient(env);
    client.login(oimUserName, oimPassword);
    System.out.println("Login Successful");
    // get the RequestService to get details of the request
    oracle.iam.request.api.RequestService reqSvc =
    (oracle.iam.request.api.RequestService)client.getService(
    oracle.iam.request.api.RequestService.class);
    // get the Request ID from the composite
    Object obj = getVariableData("inputVariable",              
    "payload",               
    "/client:process/ns1:RequestID");
    String reqId = ((oracle.xml.parser.v2.XMLElement)obj).getText();  
    System.out.println("request ID: "+reqId);
    // invoke the getBasicRequestData() method on the RequestService API
    oracle.iam.request.vo.Request req = reqSvc.getBasicRequestData(reqId);
    // print the results
    System.out.println(req.getRequestStatus());
    System.out.println(req.getRequestTemplateName());
    System.out.println(req.getRequestModelName());
    System.out.println(req.getCreationDate());
    } catch (Exception e) {
    e.printStackTrace();
    }

Leave a Reply

Your email address will not be published. Required fields are marked *