Accessing the SOA runtime environment from BPEL

In this recipe, we will embed a snippet of Java code into our BPEL process.

How to do it...

  1. Open your BPEL process in the BPEL process editor.
  2. Drag a Java Embedding activity from Component Palette under the Oracle Extensions section onto the BPEL process, to create an Exec activity.
    How to do it...
  3. Access the BPEL process variables.

    Double-click the Java activity to open the Edit Java Embedding dialog, and enter the Java code to be executed.

    How to do it...

    BPEL variables can be read by using the getVariableData method that is predefined. This method takes three parameters, namely the variable name, the message part (if it is a message variable), and the XPath expression (if any). The XPath expression must use appropriate namespace prefixes declared in the BPEL process.

    org.w3c.dom.Element elem = (org.w3c.dom.Element)getVariableData("inputVariable", "payload", "/client:process/client:input");

    The setVariableData method is used to write to variables in the BPEL process. This takes up to four parameters, with the fourth parameter being the data that we need to store in the BPEL variable.

    setVariableData("outputVariable", "payload", "/client:processResponse/client:result", "Response");

How it works...

The Java embedding activity causes the Java code to be included in the code that is generated when the BPEL process is compiled. This is actually an instance of an extension of the com.collaxa.cube.engine.ext.bpel.v1.nodes.BPELXExecLet class. This class is part of the BPEL process and is used to implement the Exec activity. Any namespace prefixes in the scope of the BPEL process may be used in XPath expressions in the embedded Java code.

There's more...

Generally, it is more flexible to write a custom XPath function than use Java embedding, because a custom XPath function can be re-used across BPEL and Mediator components in different composites.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.21.47