Oracle® BPEL Process Manager Order Booking Tutorial 10g (10.1.3.1.0) Part Number B28987-01 |
|
|
View PDF |
This chapter of the tutorial describes how to add transformation logic to a BPEL process.
This chapter contains the following topics:
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:
Create a new BPEL process named POAcknowledge.
Design the BPEL process to add transformation logic to transform incoming purchase order data into outgoing purchase order acknowledgment data.
Test the transformation logic. This is a standalone test, and does not involve designing or deploying the complete process. You simply build and test the transformation logic from Oracle JDeveloper.
This section contains the following tasks:
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.Right-click OrderBookapplication and select New Project.
Under Categories, expand General and click Projects.
Under Items, click BPEL Process Project and click OK.
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 |
Click the flashlight icon to the right of the Input Schema Element field.
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.
Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.
Click OK.
The POAcknowledgeRequestMessage message type is automatically assigned an input message part name of payload and message part element of PurchaseOrder.
Click the flashlight icon to the right of the Output Schema Element field.
The Type Chooser window appears.
Click the first icon in the upper right corner (named Import Schema File).
The Import Schema window appears.
Click the flashlight icon to the right of the URL field.
In the Select Schema window, select POAcknowledge.xsd
from the SOA_Oracle_Home
\bpel\samples\tutorials\127.OrderBookingTutorial\PracticeFiles
directory and click Open.
Click OK on the Import Schema File window.
This imports the purchase order schema into your project.
The Type Chooser window appears.
Expand and select the second Imported Schemas > POAcknowledge.xsd > POAcknowledge.
Click OK.
The POAcknowledgeResponseMessage message type is automatically assigned an output message part name of payload and message part element of POAcknowledge.
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.
Select Save from the File main menu.
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.
Expand Message Types > Process WSDL - POAcknowledge.wsdl > POAcknowledgeRequestMessage > payload in the Structure section.
Right-click payload and select Edit Message Part to display the Edit Message Part window.
Note that this defines the (input parameter) message part name (payload) of the PurchaseOrder element type.
Click Cancel.
Expand Message Types > Process WSDL - POAcknowledge.wsdl > POAcknowledgeResponseMessage > payload in the Structure section.
Right-click payload and select Edit Message Part to display the Edit Message Part window.
Note that this defines the (output parameter) message part name (payload) of the POAcknowledge element type.
Click Cancel.
Summary:
You now use a Transform activity to create a transformation that maps incoming purchase order data into outgoing purchase order acknowledgment data.Drag and drop a Transform activity between the receiveInput Receive activity and the callbackClient Invoke activity.
Double-click the Transform activity.
Click the General tab.
Enter transformPO in the Name field.
Click the Transformation tab to display the Transformation window.
Select inputVariable in the Source Variable field (this automatically selects payload in the Source Part field).
Select outputVariable in the Target Variable field (this automatically selects payload in the Target Part field).
Click the second icon (the Create Mapping icon) to the right of the Mapper File field.
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.
Right-click the source and target schemas (the top-most elements in both lists) and select Expand All.
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:
Note:
If you drag and drop a source element to the wrong target element, right-click the connecting line and select Delete.Select String Functions from the Component Palette section.
Drag and drop a concat function into the middle of the transformation window.
Go to the po:ShipTo > po:Name source section.
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.
Go to the ShippingAddress target section.
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.
Drag and drop another concat function into the middle of the transformation window to map source BillTo to target BillingAddress.
Go to the po:BillTo > po:Name source section.
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.
Go to the BillingAddress target section.
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.
Select and right-click the target Items. This displays a list of XSL functions.
Select Add XSL Node > for-each.
Go to the source po:OrderItems section.
Drag and drop the source po:Item onto the for-each link.
Drag and drop the source po:Item onto the target Items (below the for-each link).
Click OK when prompted to confirm your mapping. This automatically maps all subelements.
This defines a relationship that specifies a one-to-many (1:M) mapping between the source and target.
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 |
Select Save from the File main menu.
Right-click in the transformation mapping window and select Test.
This displays the Test XSL Map window.
Ensure that Generate Source XML Data is selected.
This creates sample XML test data.
Accept all other default settings.
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.
Verify the results.
Select Save from the File main menu.
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.
A translation file named Transformation_1.xsl appears under POAcknowledge > Integration Content in the Application Navigator section.
You have now added transformation logic to a BPEL process. You performed the following key tasks:
Created a new BPEL process named POAcknowledge.
Designed the BPEL process to add transformation logic that transformed incoming purchase order data into outgoing purchase order acknowledgment data.
Tested the transformation logic and reviewed the results. You did not design or deploy the complete process. That comes in later phases of this tutorial.