Skip Headers
Oracle® BPEL Process Manager Order Booking Tutorial
10g (10.1.3.1.0)

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

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

7 Adding Transformation Logic

This chapter of the tutorial describes how to add transformation logic to a BPEL process.

This chapter contains the following topics:

7.1 Introduction

This phase of the tutorial adds to the process you designed in Chapter 6, "Creating Fault Handling and Exception Management". Ensure that you have successfully completed that phase before performing this one. In this phase of the tutorial, you add transformation logic to a new BPEL process. You perform the following key tasks:

7.2 Adding Transformation Logic

This section contains the following tasks:

7.2.1 Creating the POAcknowledge Project and Importing the Schema

From Oracle JDeveloper, follow these instructions to create the POAcknowledge project and import the schema.

Caution:

Do not include any special characters in the project name (such as periods) or in any activity or element names. If you do include special characters, errors appear when you attempt to compile your project.
  1. Right-click OrderBookapplication and select New Project.

  2. Under Categories, expand General and click Projects.

  3. Under Items, click BPEL Process Project and click OK.

  4. In the BPEL Project Creation Wizard - Project Settings window, enter the following details and click Next.

    Field Value
    Name POAcknowledge
    Namespace Accept the default path.
    Use Default Project Settings Leave this checked to use the same name for the BPEL process and the BPEL project, and to use the default project directory.
    Template Asynchronous BPEL Process

  5. Click the flashlight icon to the right of the Input Schema Element field.

  6. In the Select Schema window, select OrderBookingPO.xsd from the SOA_Oracle_Home\bpel\samples\tutorials\127.OrderBookingTutorial\PracticeFiles directory and click Open.

    This imports the purchase order schema into your project.

    The Type Chooser window appears.

  7. Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.

  8. Click OK.

    The POAcknowledgeRequestMessage message type is automatically assigned an input message part name of payload and message part element of PurchaseOrder.

  9. Click the flashlight icon to the right of the Output Schema Element field.

    The Type Chooser window appears.

  10. Click the first icon in the upper right corner (named Import Schema File).

    The Import Schema window appears.

  11. Click the flashlight icon to the right of the URL field.

  12. In the Select Schema window, select POAcknowledge.xsd from the SOA_Oracle_Home\bpel\samples\tutorials\127.OrderBookingTutorial\PracticeFiles directory and click Open.

  13. Click OK on the Import Schema File window.

    This imports the purchase order schema into your project.

    The Type Chooser window appears.

  14. Expand and select the second Imported Schemas > POAcknowledge.xsd > POAcknowledge.

  15. Click OK.

    The POAcknowledgeResponseMessage message type is automatically assigned an output message part name of payload and message part element of POAcknowledge.

  16. Click Finish.

    The following files appear in the Application Navigator:

    • The bpel.xml, POAcknowledge.bpel, and POAcknowledge.wsdl files appear under POAcknowledge > Integration Content.

    • The POAcknowledge.xsd and OrderBookingPO.xsd files appear under POAcknowledge > Integration Content > Schemas.

  17. Select Save from the File main menu.

  18. If you want to view the message part name and element that were automatically assigned to your message types during BPEL project creation, ensure that POAcknowledge.bpel is displayed and perform the following steps.

    1. Expand Message Types > Process WSDL - POAcknowledge.wsdl > POAcknowledgeRequestMessage > payload in the Structure section.

    2. Right-click payload and select Edit Message Part to display the Edit Message Part window.

    3. Note that this defines the (input parameter) message part name (payload) of the PurchaseOrder element type.

    4. Click Cancel.

    5. Expand Message Types > Process WSDL - POAcknowledge.wsdl > POAcknowledgeResponseMessage > payload in the Structure section.

    6. Right-click payload and select Edit Message Part to display the Edit Message Part window.

    7. Note that this defines the (output parameter) message part name (payload) of the POAcknowledge element type.

    8. Click Cancel.

7.2.2 Creating a Transform Activity

Summary:

You now use a Transform activity to create a transformation that maps incoming purchase order data into outgoing purchase order acknowledgment data.
  1. Drag and drop a Transform activity between the receiveInput Receive activity and the callbackClient Invoke activity.

  2. Double-click the Transform activity.

  3. Click the General tab.

  4. Enter transformPO in the Name field.

  5. Click the Transformation tab to display the Transformation window.

  6. Select inputVariable in the Source Variable field (this automatically selects payload in the Source Part field).

  7. Select outputVariable in the Target Variable field (this automatically selects payload in the Target Part field).

  8. Leave the Mapper File field selection as Transformation_1.

  9. Click the second icon (the Create Mapping icon) to the right of the Mapper File field.

    Description of create_mapping.gif follows
    Description of the illustration create_mapping.gif

    A window for graphically mapping source and target elements appears. This window enables you to drag (map) a source element to a target element. If you instead receive a message saying the file already exists, click the third icon to access the transformation window.

  10. Right-click the source and target schemas (the top-most elements in both lists) and select Expand All.

    Description of obph6trans1.gif follows
    Description of the illustration obph6trans1.gif

  11. Drag and drop the following source elements to the following target elements. As you perform this task, a line connects each source to its target.

    Note:

    The namespace values that appear for the source (for example, ns1, po) can vary. Use the namespace values that automatically appear.
    Drag the Source... To the Target...
    po:CustID CustomerID
    po:ID ID
    po:ShipTo ShippingAddress

    Note: Click OK when prompted to confirm your mapping. Connecting this source and target automatically connects all subelements.


    The Transformation window appears as follows:

    Description of obph6trans2.gif follows
    Description of the illustration obph6trans2.gif

    Note:

    If you drag and drop a source element to the wrong target element, right-click the connecting line and select Delete.
  12. Select String Functions from the Component Palette section.

  13. Drag and drop a concat function into the middle of the transformation window.

  14. Go to the po:ShipTo > po:Name source section.

  15. Drag the po:First and po:Last source elements below po:ShipTo > po:Name into the left side of the concat function. This connects two source lines to the concat function.

  16. Go to the ShippingAddress target section.

  17. Drag the Name target element into the right side of the concat function. This connects the target line to the concat function and concatenates the first and last names from the source elements into a single name in the target element.

    Description of obph6trans3.gif follows
    Description of the illustration obph6trans3.gif

  18. Drag and drop another concat function into the middle of the transformation window to map source BillTo to target BillingAddress.

  19. Go to the po:BillTo > po:Name source section.

  20. Drag the po:First and po:Last source elements below po:BillTo > po:Name into the left side of the concat function. This connects two source lines to the concat function.

  21. Go to the BillingAddress target section.

  22. Drag the Name target element into the right side of the concat function. This connects the target line to the concat function and concatenates the first and last names from the source elements into a single name in the target element.

    Description of obph6trans5.gif follows
    Description of the illustration obph6trans5.gif

  23. Select and right-click the target Items. This displays a list of XSL functions.

  24. Select Add XSL Node > for-each.

    The for-each node appears above the target Items.

  25. Go to the source po:OrderItems section.

  26. Drag and drop the source po:Item onto the for-each link.

  27. Drag and drop the source po:Item onto the target Items (below the for-each link).

  28. Click OK when prompted to confirm your mapping. This automatically maps all subelements.

    Description of obph6trans7.gif follows
    Description of the illustration obph6trans7.gif

    This defines a relationship that specifies a one-to-many (1:M) mapping between the source and target.

  29. Drag and drop the remaining source purchase order elements to the target purchase order acknowledge elements:

    Drag the Source... To the Target...
    po:SupplierPrice SupplierPrice
    po:SupplierName SupplierName
    po:OrderDate OrderDate
    po:OrderPrice OrderPrice
    po:OrderStatus OrderStatus

    Description of obph6trans8.gif follows
    Description of the illustration obph6trans8.gif

  30. Select Save from the File main menu.

7.2.3 Testing the Transformation Logic

  1. Right-click in the transformation mapping window and select Test.

    This displays the Test XSL Map window.

  2. Ensure that Generate Source XML Data is selected.

    This creates sample XML test data.

  3. Accept all other default settings.

    Description of obph6test.gif follows
    Description of the illustration obph6test.gif

  4. Click OK to test the translation logic.

    Sample test results appear. The source XML and target XML display data side-by-side, with the XSL map data underneath. This is the default layout of test results.

    Description of obph6test2.gif follows
    Description of the illustration obph6test2.gif

  5. Verify the results.

  6. Select Save from the File main menu.

  7. Close the Transformation_1-Source.xml, Transformation_1-Target.xml, and Transformation_1.xsl files by clicking the x button for each in the Title tab.

    Description of obph9trans7.gif follows
    Description of the illustration obph9trans7.gif

    A translation file named Transformation_1.xsl appears under POAcknowledge > Integration Content in the Application Navigator section.

7.3 Summary

You have now added transformation logic to a BPEL process. You performed the following key tasks: