Assign Activity:
The Assign Activity is an important activity that is going to be used quite often, as it enables you to assign a value to a variable. You can use an Assign activity to increment the value of a variable in a loop.
Using an Assign Activity:
The starting point for data manipulation in BPSL is the assign activity, which builds on the XPath standard. You can use the assign activity to copy data from one XML variable to another or calculate the value of an expression and store it in a variable.
A copy element within the activity specifies the source and target of the assignment, which must be of compatible types. You can use XPath queries, expressions and functions to manipulate data as follows:
- XPath queries: An XPath query selects a field within a source or target variable part. The form or to clause can include a query attribute whose value is an XPath query string.
- XPath Expressions: You use an XPath expression to indicate a value to be stored in a variable.
The expression can be any general expression – that is an XPath expression that evaluates to any XPath value type. Within XPath expressions, you can call the following types of functions:
- Core XPath functions
- BPEL extension functions
- BPEL XPath extension functions
- Custom functions
How to us an Assign Activity?
You use the copy operation within the assign activity to specify which data is being copied into which variable. In the SOA Order Booking application, the BPEL process uses an assign activity, Initialize Request, to copy the value of the credit card type variable to the cc type variable and to copy the value of the credit card number variable to the value of the cc Num variable. The variable names ccType and ccNum are specified in the WSDL of the Credit Validating Service partner link.
To copy variables using an assign activity:
1. Drag and drop an Assign activity inside a Scope activity.
2. Double-click the Assign icon.
3. Use the General tab of the Assign dialog to enter a name for the Assign activity.
4. Click Apply.
5. Click the Copy Operation tab.
6. From the create list, select Copy Operation.
7. Use the Create Copy Operation dialog, to copy the contents of one variable to another. This Assign activity takes the client’s purchase order as input and contacts the Rapid Manufacturer web service for a price quote.
-
i. Browse for the From Variable by expanding the tree until you find the client input variable name.
ii. Browse for the To Variable by expanding the tree until you find the input variable name used by the web service.
8. Close the Create Copy Operation and Assign windows.
9. Save the file.