Skip Headers
Oracle® SOA Suite Developer's Guide
10g (10.1.3.1.0)

Part Number B28764-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

7.4 Using an Assign Activity

The starting point for data manipulation in BPEL is the assign activity, which builds on the XPath standard. As shown in Figure 7-10, you use the assign activity to copy data from one XML variable to another, or to calculate the value of an expression and store it in a variable.

Figure 7-10 Assign Dialog for Copy Operations

Description of Figure 7-10 follows
Description of "Figure 7-10 Assign Dialog for Copy Operations"

A copy element within the activity specifies the source and target of the assignment (what to copy from and to), which must be of compatible types.

You can use XPath queries, expressions, and functions to manipulate data as follows:

See Oracle BPEL Process Manager Developer's Guide for more information about these functions.

Sophisticated data manipulation can be difficult to perform with the BPEL assign activity and the core XPath functions. However, you can perform complex data manipulation and transformation by using XSLT or Java, or as a web service. For XSLT, Oracle BPEL Process Manager includes XPath functions that execute these transformations. See the following for information about transformations:

7.4.1 How to Use an Assign Activity

You use the copy operation within the assign activity to specify which data is being copied into which variable, as shown in Figure 7-10. In the SOA Order Booking application, the BPEL process uses an assign activity, InitializeRequest, (within the CreditService scope) to copy the value of the creditcardtype variable to the ccType variable, and to copy the value of the creditcardnumber variable to the value of the ccNum variable. The variable names ccType and ccNum are specified in the WSDL of the CreditValidatingService 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, shown in Figure 7-8, 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.

    Figure 7-11 Copy Operation Dialog

    Description of Figure 7-11 follows
    Description of "Figure 7-11 Copy Operation Dialog"

    1. Browse for the From Variable by expanding the tree until you find the client input variable name (as defined in the BPEL process WSDL file).

    2. Browse for the To Variable by expanding the tree until you find the input variable name used by the web service (as defined in the message type definition of the web service WSDL).

  8. Close the Create Copy Operation and Assign windows.

  9. Save the file.

7.4.2 What Happens When You Use an Assign Activity

Example 7-4 shows the source code for the InitializeRequest assign activity in the SOA Order Booking application.

Example 7-4 Source Code for the InitializeRequest Assign Activity

<scope name="CreditService">
  <variables>
    <variable name="validateRequest"
              messageType="ns6:CreditCardValidationRequestMessage"/>
    <variable name="validateResponse"
              messageType="ns6:CreditCardValidationResponseMessage"/>
   </variables>
     <sequence name="Sequence_5">
       <assign name="InitializeRequest">
         <copy>
           <from variable="customerServiceResponse"
                 query="/ns3:findCustomerByIdResponse/ns3:return/ns3:creditcardtype"
                 part="parameters"/>
           <to variable="validateRequest" part="CreditCard"
               query="/ns21:CreditCard/ccType"/>
         </copy>
         <copy>
           <from variable="customerServiceResponse"
                 query="/ns3:findCustomerByIdResponse/ns3:return/ns3:creditcardnumber"
                 part="parameters"/>
           <to variable="validateRequest" part="CreditCard"
               query="/ns21:CreditCard/ccNum"/>
         </copy>
       </assign