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 invoke a synchronous service.
This chapter contains the following topics:
In the first phase of this tutorial, you learn how to build a simple asynchronous BPEL process for receiving an order from a client and obtaining a credit rating. You perform the following key tasks:
Deploy (start) a synchronous Credit Rating service.
Create a new BPEL process named OrderBooking.
Create a partner link to interact with the synchronous Credit Rating service.
Design the BPEL process to invoke the synchronous Credit Rating service.
Deploy the BPEL process.
Run the deployed BPEL process from Oracle BPEL Control and submit a social security card number to the Credit Rating service to check the client's credit history.
Review the credit rating results returned from the Credit Rating service to the client.
This section contains the following topics:
Creating an Initial Assign Activity to Send a Request to the Credit Rating Service
Creating a Second Assign Activity to Receive a Response from the Credit Rating Service
Validating, Compiling, and Deploying the Order Booking Process
Ensure that Oracle BPEL Server and Oracle JDeveloper are started. See "Starting Oracle BPEL Process Manager Components" for instructions.
During this tutorial, the BPEL process that you design communicates with the Credit Rating service. You must first deploy this service and test that it is running.
Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > Developer Prompt to open up an operating system command prompt at the SOA_Oracle_Home
\bpel\samples
directory.
Change directories to the utils\CreditRatingService
subdirectory:
cd utils\CreditRatingService
Enter the following command:
ant
This deploys and starts the required services for using this tutorial. If successful, a message similar to the following appears at the end:
BUILD SUCCESSFUL Total time: 3 seconds oraBPELPM\bpel\samples\utils\CreditRatingService>
If you receive an error saying the path was not found, ensure that your environment path is set to the SOA_Oracle_Home
\bpel\bin
directory.
Access Oracle BPEL Control using Internet Explorer to see if all required services are running. Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > BPEL Control.
Enter the following details to log into Oracle BPEL Control and click Login:
Field | Value |
---|---|
Username | oc4jadmin |
Password | password |
Where password
is the value you entered during installation in "Installing Oracle Application Server SOA Suite".
The services for this tutorial are running if CreditRatingService, TaskActionHandler, and TaskManager display in the Dashboard tab.
See Also:
"Creating Oracle Application Server and Integration Server Connections" for instructions on creating a connection to Oracle BPEL ControlFrom Oracle JDeveloper, follow these instructions to create an application before creating the Order Booking project.
In the Application Navigator, right-click Applications and select New Application.
In the Create Application window, enter the following details and click OK:
Field | Value |
---|---|
Application Name | OrderBookapplication |
Directory Name | Accept the default path. |
Application Package Prefix | Leave unspecified. |
Application Template | No Template [All Technologies] |
In the Create Project window, click Cancel.
From Oracle JDeveloper, follow these instructions to create the Order Booking 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 the application name you just created, 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 | OrderBooking |
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.
The Type Chooser window appears.
Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.
Click OK.
The OrderBookingRequestMessage 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.
Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.
Click OK.
The OrderBookingResponseMessage message type is automatically assigned an output message part name of payload and message part element of PurchaseOrder.
Click Finish.
The GlobalCompany schema is now imported into your project. This schema defines the structure of the purchase order to submit.
The following files appear in the Application Navigator section of Oracle JDeveloper:
The bpel.xml, OrderBooking.bpel, and OrderBooking.wsdl files appear under OrderBooking > Integration Content.
The OrderBookingPO.xsd file appears under OrderBooking > Integration Content > Schemas.
If you want, you can double-click OrderBookingPO.xsd to view the design and source modes of this file.
If you view OrderBookingPO.xsd, close the window when done by clicking the X button on the Title tab.
Double-click OrderBooking.bpel to display the Structure section in the lower left of the window.
Note:
The Diagram tab must be enabled to see the Structure section.Copy OrderBookingPO_1.xml
from the SOA_Oracle_Home
\bpel\samples\tutorials\127.OrderBookingTutorial\PracticeFiles
directory to the JDev_Oracle_Home
\jdev\mywork\OrderBookapplication\OrderBooking
directory.
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, perform the following steps.
Expand Message Types > Process WSDL - OrderBooking.wsdl > OrderBookingRequestMessage > payload in the Structure section.
Right-click payload and select Edit Message Part to display the Edit Message Part window.
This defines the (input parameter) message part name (payload) of the PurchaseOrder element type.
Click Cancel.
Expand Message Types > Process WSDL - OrderBooking.wsdl > OrderBookingResponseMessage > payload in the Structure section.
Right-click payload and select Edit Message Part to display the Edit Message Part window.
This defines the (output parameter) message part name (payload) of the PurchaseOrder element type.
Click Cancel.
As you design your BPEL project, small yellow flags can display above activities. You may have correctly configured these activities; they simply may not yet have been validated.
Click Validate above the designer window to validate your process.
If the activity correctly validates, the flag disappears.
If the yellow flag remains, you still have validation errors in activities or your process design is not yet complete.
Click the yellow flag above the activity to display details about the validation error and corrective actions to follow.
Note:
When you deploy a process, as described in "Validating, Compiling, and Deploying the Order Booking Process", your process is automatically validated, compiled, and, if successful, deployed together.Summary:
You now create a partner link for the Credit Rating service. This is the service you started when you ranant
in "Starting and Testing Your Services". A partner link enables you to define the external services with which the OrderBooking BPEL process is to interact. A partner link type characterizes the conversational relationship between two services by defining the roles played by each service in the conversation and specifying the port type provided by each service to receive messages within the context of the conversation.Ensure that Services is selected in the drop-down list of the Component Palette section in the upper right section of Oracle JDeveloper. The Services list displays the adapters, partner link, and decision service that you can drag and drop into the designer window.
Drag and drop a PartnerLink activity onto the right side of the designer window anywhere beneath the header Services. Note that both sides of the designer window have sections in which partner links can be placed.
Enter the following values to create a partner link for the Credit Rating service. For the WSDL File field below, click the flashlight (the second icon from the left named Service Explorer) to access the Service Explorer window for automatically selecting the Credit Rating service deployed in "Starting and Testing Your Services":
Field | Value |
---|---|
Name | CreditRatingService |
WSDL File | Access this URL by clicking the Service Explorer flashlight icon and expanding and selecting BPEL Services > my_ integration_server_connection > processes > default > CreditRatingService
where my_integration_server_connection is the server connection name you specified in Step 17. http://localhost:8888/orabpel/default/CreditRatingService/CreditRatingService?wsdl See Also: "Setting the Hostname in Your Oracle JDeveloper Web Browser Preferences" if you receive a parsing error when attempting to add a WSDL file in the Service Explorer window. |
Partner Link Type | CreditRatingService |
Partner Role | CreditRatingServiceProvider |
My Role | Leave unspecified since this is a synchronous service. |
Click OK.
Select Save from the File main menu.
Summary:
You now create the Invoke activity that sends request data from the OrderBooking process to the synchronous Credit Rating service and receives a response. The customer custID variable from the Order Booking schema is used to obtain the credit rating. When you run the OrderBooking process, you specify a value for CustID in Step 4 of "Running the Order Booking Process".Ensure that Process Activities is selected in the drop-down list of the Component Palette section in the upper right section of Oracle JDeveloper. The Process Activities list displays the activities that you can drag and drop into the designer window.
Drag and drop a Scope activity from the Component Palette section to below the receiveInput Receive activity. Always pay careful attention to where you place the Scope activity; throughout all phases of this tutorial, you drag and drop activities many times.
Note that the first time your drag and drop an activity, it has a generic name such as Scope_1.
Double-click the scope icon to display the Scope window.
Enter GetCreditRating in the Name field of the General tab.
Click OK.
Click the + sign to expand the Scope activity. You now add an Invoke activity and two Assign activities to this Scope activity.
Drag and drop an Invoke activity from the Component Palette section to inside the GetCreditRating Scope activity.
Double-click the Invoke icon to display the Invoke window.
Enter the following details:
Field | Value |
---|---|
Name | invokeCR |
Partner Link | CreditRatingService |
The Operation (process) field is automatically filled in.
Click the first icon to the right of the Input Variable field. This is the automatic variable creation icon.
Click OK on the Create Variable window.
A variable named invokeCR_process_InputVariable is automatically created in the Input Variable field. This variable is automatically assigned a message type of CreditRatingServiceRequestMessage.
Click the first icon to the right of the Output Variable field.
Click OK on the Create Variable window.
A variable named invokeCR_process_OutputVariable is automatically created in the Output Variable field. This variable is automatically assigned a message type of CreditRatingServiceResponseMessage.
Click OK.
Select Save from the File main menu.
Summary:
You now create the first of two Assign activities in this phase. This Assign activity takes the customer custID element from the Order Booking schema and assigns it to invokeCR_process_InputVariable. This is the variable used for sending a request to the Credit Rating service.Drag and drop an Assign activity from the Component Palette section to above the invokeCR Invoke activity and inside the GetCreditRating Scope activity.
Double-click the assign icon to display the Assign window.
Click the General tab.
Enter assignCR in the Name field.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation to display the Create Copy Operation window.
Field | Value |
---|---|
From | |
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:CustID
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespaces values that automatically appear. |
To | |
|
Variable |
|
Expand and select Variables > invokeCR_process_InputVariable > payload > ns2:ssn |
The Create Copy Operation window appears as follows:
Click OK to close the Create Copy Operation window and the Assign window.
Select Save from the File main menu.
Summary:
This Assign activity takes the response received from the Credit Rating service and places it in the comment field.Drag and drop an Assign activity from the Component Palette section to below the invokeCR Invoke activity and inside the GetCreditRating Scope activity.
Double-click the assign icon to display the Assign window.
Click the General tab.
Enter assignRating in the Name field.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation to display the Create Copy Operation window.
Notes:
Instead of manually entering an expression, you can press Ctrl and then the space bar in the Expression field. Scroll through the list of values that appears and double-click the value you want. Edit the value as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.
Do not copy and paste the expression syntax shown in this document into Oracle JDeveloper. This is because the single and double quotation marks are sometimes not compatible with Oracle JDeveloper. Instead, use the Expression Builder window or press Ctrl and then the space bar to use the XPath Building Assistant.
Field | Value |
---|---|
From | |
|
Expression |
|
concat('Good credit, Rating = ', bpws:getVariableData('invokeCR_process_OutputVariable','payload','/ns2:rating'))
Note: Press Ctrl and then the space bar to display a list for selecting (double-clicking) this syntax. The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
To | |
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments |
Click OK to close the Create Copy Operation window and the Assign window.
Click the - sign to close the GetCreditRating Scope activity.
When closed, the GetCreditRating Scope activity looks as follows:
Select Save from the File main menu.
Drag and drop an Assign activity from the Component Palette section to below the GetCreditRating Scope activity and above the callbackClient activity.
Double-click the assign icon to display the Assign window.
Click the General tab.
Enter assignOutput in the Name field.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation to display the Create Copy Operation window.
Enter the following details to create a statement:
Field | Value |
---|---|
From | |
|
Variable |
|
Expand and select Variables > inputVariable > payload |
To | |
|
Variable |
|
Expand and select Variables > outputVariable > payload |
Click OK to close the Create Copy Operation window and the Assign window.
Select Save from the File main menu.
When complete, the designer window looks as follows:
Go to the Application Navigator section.
Right-click OrderBooking.
Select Deploy > my_integration_server_connection > Deploy to default domain.
where my_integration_server_connection is the integration server connection name you specified in Step 17.
This compiles the BPEL process.
Check for errors by clicking the buttons at the bottom of the window. Errors that do not display under the Messages button can sometimes appear under the Apache Ant button.
If there are no errors, deployment was successful. If there are errors, double-click the error to display details about the type and location of the error.
Make corrections and deploy again.
You are now ready to begin the process of applying for a new order.
Access Oracle BPEL Control using Internet Explorer or refresh the page if it is already open. Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > BPEL Control.
Enter the following details to log into Oracle BPEL Control and click Login:
Field | Value |
---|---|
Username | oc4jadmin |
Password | password |
Where password
is the value you entered during installation.
The Dashboard tab of Oracle BPEL Control appears.
Click OrderBooking in the Deployed BPEL Processes list.
Enter a nine-digit integer value that does not begin with zero in the CustID field of the HTML Form and click Post XML Message. Ignore the other fields.
The BPEL Processes tab displays a message similar to the following:
Test Instance Initiated
Instance '39e706a46ad531be:858bf1:fcc240f310:-7ffc' is being processed asynchronously.
Click the Instances tab at the top.
Verify that the OrderBooking and CreditRatingService instances were created. Both should appear in the Instance list. The Last Modified list displays the times at which they were created.
Click the OrderBooking instance.
A message appears stating the following:
The state of this instance is Completed
Click the Audit link to follow the instance execution process. The Audit link displays the following details:
Click callbackClient at the bottom of the flow to see the results.
Verify the credit rating value. The comment field shows that the credit rating is returned as 560; this is also returned in the variable invokeCR_process_OutputVariable.
You have now built a simple asynchronous BPEL process that received an order from a client and obtained a credit rating from a synchronous Credit Rating service. You performed the following key tasks:
Deployed a synchronous Credit Rating service.
Created a new project named OrderBooking, which automatically created a BPEL process of the same name.
Created a partner link that enabled you to define the external service (the deployed Credit Rating service) with which your BPEL process interacted.
Designed the BPEL process and invoked the Credit Rating service by creating all necessary activities.
Deployed the BPEL process to Oracle BPEL Control.
Ran the BPEL process from Oracle BPEL Control and submitted a social security card number to the Credit Rating service, which checked the client's credit history.
Reviewed the credit rating results returned from the Credit Rating service to the client.