Copying content between the variables

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.

Getting ready

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).

How to do it…

The following steps explain how to copy content between variables in a BPEL process:

  1. Open the VarCopy1_1 BPEL process and add the assign (AssignCopy) activity.
  2. Double-click on the assign activity. The Edit Assign dialog appears as shown in the following screenshot:
    How to do it…
  3. The top part of the Copy Rules tab is divided into three sections. We can consider the left side as the 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.
  4. We copy the variable content by dragging the variable from the left part and dropping it on the variable on the right side. Upon completion, click on the Apply or OK button to confirm the copying rules.

How it works…

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.

There's more…

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:

There's more…

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:

There's more…

Tip

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.

See also

  • By changing the rule type, we influence the way in which new data is introduced into the variable. The choices in the Edit Assign dialog are presented as BPELX extensions. Refer to the Updating the variables using the BPELX extensions recipe to explore how to use the BPELX extensions in a BPEL process.
..................Content has been hidden....................

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