Use the assign activity to manipulate data within your
BPEL process and map data from one location to another.
About this task
To configure an assign activity, proceed as follows:
Procedure
- From the palette, drop an assign activity onto the canvas.
- Click the Details tab in the properties
area. You will now see a table that has one column labelled Assign
From, and another labelled Assign To.
Quite simply the value in the left column is assigned into the location
specified in the column on the right.
- Click Add to create a new row, or Remove to
delete an existing one. You can change the order of the rows with
the Up and Down buttons.
Note: - The order shown here represents the sequence in which the copies
will be executed in the runtime environment, so variables must be
initialized accordingly. For example, the second copy cannot use a
variable that is initialized by third copy.
- When an existing assignment can be modified, the Edit
Query icon (
) will appear
in the cell. Click this icon to make the necessary changes.
- In the Assign From column, click Select
From. A content assist dialogue will appear
with the following options:
| Option |
Description |
| Input |
Choose this to select a variable. |
| Date |
Use the interactive calender display to choose a date. |
| String |
Enter an appropriate textual value. |
| Number |
Enter an appropriate numeric value. |
| Boolean |
Choose either True or False from
the dialogue. |
| XPath Expression |
This choice will launch the XPath Expression Builder that
you can use to visually compose an appropriate XPath expression. |
| XML Literal |
Enter the appropriate well-formed XML code. Note: An XM Literal
builder is provided to allow you to easily generate XML code using
a simple interface. Also note that you must set the Assign
To value before defining the Assign From as
an XML Literal.
|
| Property of a variable |
Choose this to select an appropriate property from an existing
variable. |
| Partner reference |
Choose this to select a partner. |
| Endpoint Reference |
This choice will launch the Select Endpoint Reference window.
Use it to specify an existing interface with an endpoint, or specify
the URI explicitly. |
- In the Assign To column, click Select
To. A content assist dialogue will appear with
options that are appropriate to the to the choice made in the Assign
From column. Choose something appropriate.
Example: using arrays in assign and forEach activities
This
example will demonstrate how you can use an assign activity to iterate
an array within a forEach activity (you can also go to
WS-BPEL 2.0 forEach activity - a typical usage pattern for
another example).
- Create a business object called MyBO with an
element called array of type string,
and with the property of array.
- Create a new BPEL process, and have the interface generated automatically.
- Create a new variable called VarArray in your
BPEL process that calls MyBO.
- Drop an assign activity between the existing Receive and Reply
activities, and create three values as follows:
- In the Assign from field, open the code
assist, select String (enter a value), and
type test 01.
- In the corresponding Assign To field, select . The value VarArray array[1] appears
in the field.
- Click Add to create a new field in the assign activity.
- Repeat these steps twice more, increasing the numeric value each
time so that it matches the following screen capture:
Note: You will not
be able to edit the
Assign To value directly.
To make changes to
array [1], click the
Edit
Query icon (

, and make
changes to the field in the
XPath Expression Builder window.
- Drop a forEach activity below the assign activity, and configure
it as follows:
- In the Details tab, under the Iteration heading,
click none in the Type field,
and select .
- Drop an assign activity into the forEach activity.
- In the Assign from field, select .
- Modify the automatically generated VarArray array[1] to
be VarArray array[bpws:getVariableData('Index')].
- In the corresponding Assign To field, select Input
1: string.
- Drop a snippet activity below the assign activity, and add the
following code to it: System.out.println( "In ForEach: " +
Input1 );.
Your completed BPEL process will look like this: