This recipe explains how to send the data to the BPEL process variable.
In order to complete the recipe, we will update the BPEL_and_Java_1_1
process schema (BPEL_and_Java_1_1.xsd
). The new element in the response message is clientResponseMsg
:
<element name="processResponse">
<complexType>
<sequence>
<element name="resultFmtBPEL" type="string"/>
<element name="resultFmtJava" type="string"/>
<element name="clientResponseMsg" type="string"/>
</sequence>
</complexType>
</element>
The newly defined element will be used to return the changed input message to the client.
Open the BPEL_and_Java_1_1
process and insert the Java Embedding activity (SetVar
).
Double-click on the SetVar
activity to insert a code snippet.
String input_txt_from_var= (String)getVariableData("Input_Txt_Var");
StringBuilder sb = new StringBuilder(); for (int i = input_txt_from_var.length() - 1; i >= 0; i--) sb.append(input_txt_from_var.charAt(i));
clientResponseMsg
element of the BPEL process output variable:setVariableData("outputVariable","payload","/client:processResponse/client:clientResponseMsg", sb.toString());
The Java Embedding activity provides three types of setVariableData
methods:
void setVariableData(String name, Object value)
void setVariableData(String name, String part, Object value)
void setVariableData(String name, String part, String query, Object value)
Depending on our needs, we choose the appropriate method. The methods have similar signatures to getVariableData
, with the difference they don't return any values and contain an additional attribute, value
, that is used to set the content of the variable.