Oracle SOA Suite defines a set of utility functions to perform various operations. However, there is no unified place where we find the utility functions. In this recipe, we will learn how to format a message with the ora:format
utility function and then implement the same functionality inside the Java Embedding activity.
To start, we will use the BPEL_and_Java_1_1
process. We change the schema definition of the response message. Open the BPEL_and_Java_1_1.xsd
file and change the response part of the element:
<element name="processResponse"> <complexType> <sequence> <element name="resultFmtBPEL" type="string"/> <element name="resultFmtJava" type="string"/> </sequence> </complexType> </element>
Open the BPEL_and_Java_1_1
process and place a new assign activity (FormatBPEL
) into it. The code for the assign activity is as follows:
<assign name="FormatBPEL"> <copy> <from expression="ora:format('At {0} on {1} the BPEL was initiated with the following input parameter: {2}.',xp20:current-time(),xp20:current-date(),bpws:getVariableData('inputVariable','payload','/client:process/client:input') )"/> <to variable="outputVariable" part="payload" query="/client:processResponse/client:resultFmtBPEL"/> </copy> </assign>
With the code, we formatted a message that contains the date and input message information. We assign the result to the output part of the variable (resultFmtBPEL
).
We will now format the same message with the help of the Java Embedding activity. Start by adding the Java Embedding activity (FormatJava
) into the BPEL_and_Java_1_1
process. The code snippet for the FormatJava
activity is as follows:
String input_txt= ((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:process/client:input")).getTextContent();
MessageFormat
class for the formatting:java.text.MessageFormat mfmt= new java.text.MessageFormat("At {0, time} on {0,date} the BPEL was intatiated with the following input parameter: {1}.");
Object[] objs = {new java.util.Date(), input_txt};
resultFmtJava
):String result= mfmt.format(objs); setVariableData("outputVariable", "payload", "/client:processResponse/client:resultFmtJava", result);
Both the methods described in this recipe use the same principle of formatting the messages. Actually, the BPEL method ora:format
uses the same Java class that we used in this recipe (java.text.MessageFormat
).
Oracle defines a set of utility functions to be utilized, summarized by the section in which we can find them in JDeveloper Expression Builder.
Function name |
What function does |
---|---|
|
Formats the message based on the Java message formatting expression. |
|
Generates the specified number of empty elements specified by QName parameter. |
|
Returns the child element (index) of the given element. |
Function name |
What the function does |
---|---|
|
Returns the maximum integer value from the list of given nodes. The nodes must be presented as text nodes. |
|
Returns the minimum integer value from the list of given nodes. The nodes must be presented as text nodes. |
|
Returns the square root of the input number |