One of the fundamental functionalities of a BPEL process is the manipulation of XML data from the request via various intermediate operations and transformations to the response. This recipe explains the principles of copying content between the variables.
For this recipe, we will clone the FromSpecBPEL.bpel
process from the previous recipe and create two BPEL processes: VarCopy1_1.bpel
(synchronous BPEL process, Version 1.1) and VarCopy2_0.bpel
(synchronous BPEL process, Version 2.0).
The following steps explain how to copy content between variables in a BPEL process:
VarCopy1_1
BPEL process and add the assign (AssignCopy
) activity.from
part and the right side as the to
part. The middle of the pane is reserved as a placeholder for various functions, such as functions, expressions, literals, and so on.Behind the scenes, the visualization is transformed into the XML code. The copy between the variables is done directly, meaning there is no need to address the variables through the XPath queries.
It is also possible to copy more than just the variables. From-spec can also contain expressions, partner links, and literals.
There is also a difference in the version of specification that our BPEL process supports. Check the source code that we have now in the VarCopy1_1
process as follows:
<copy> <from variable = "inputVariable" part = "payload" query = "/client:process/client:name"/> <to variable = "outputVariable" part = "payload" query = "/client:processResponse/client:firstName"/> </copy> // Perform the recipe on the VarCopy2_0 process. The source code // we found there is as follows: <copy> <from>$inputVariable.payload/client:name</from> <to>$outputVariable.payload/client:firstName</to> </copy>
We can see the difference in the copy definitions of both the BPEL processes. However, the outcome of the copy operation is the same in both cases.
One major difference between the BPEL 1.1 and BPEL 2.0 Edit Assign dialog is the visual presentation of the middle part of the dialog. The following screenshot is the middle part of the Edit Assign dialog from the BPEL 1.1 process:
If we compare the same dialog in the BPEL 2.0 process, we find no such elements except for the icons on the right side. This functionality can now be found if we right-click on the from-to rule part of the Edit Assign dialog and select Change rule type as shown inthe following screenshot:
The change between the versions was made mainly due to the improved data access mechanism in later BPEL processes. In Version 1.1, the variables were accessed through the XPath query. The newer version of the BPEL specification introduces different handling of the variable data access through the variable XPath binding or $notation
. The variables as well as their part definitions can now be accessed via $var.part/field
.