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

2 Invoking a Synchronous Service

This chapter of the tutorial describes how to invoke a synchronous service.

This chapter contains the following topics:

2.1 Introduction

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:

2.2 Invoking a Synchronous Service to Receive an Order and Obtain a Credit Rating

This section contains the following topics:

2.2.1 Starting Oracle BPEL Server and Oracle JDeveloper

Ensure that Oracle BPEL Server and Oracle JDeveloper are started. See "Starting Oracle BPEL Process Manager Components" for instructions.

2.2.2 Starting and Testing Your Services

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.

  1. 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.

    Note:

    Always use the Developer Prompt to open an operating system command prompt in all phases of the Order Booking tutorial. Opening an operating system command prompt in any other way to run tutorial commands is not supported.
  2. Change directories to the utils\CreditRatingService subdirectory:

    cd utils\CreditRatingService
    
    
  3. 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.

  4. 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.

  5. 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.

  6. See Also:

    "Creating Oracle Application Server and Integration Server Connections" for instructions on creating a connection to Oracle BPEL Control

2.2.3 Creating an Application

From Oracle JDeveloper, follow these instructions to create an application before creating the Order Booking project.

  1. In the Application Navigator, right-click Applications and select New Application.

  2. 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]

  3. In the Create Project window, click Cancel.

2.2.4 Creating the Order Booking Project and Importing the Schema

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.
  1. Right-click the application name you just created, 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 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

  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.

    The Type Chooser window appears.

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

  8. Click OK.

    The OrderBookingRequestMessage 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. Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.

  11. Click OK.

    The OrderBookingResponseMessage message type is automatically assigned an output message part name of payload and message part element of PurchaseOrder.

  12. 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.

  13. If you want, you can double-click OrderBookingPO.xsd to view the design and source modes of this file.

  14. If you view OrderBookingPO.xsd, close the window when done by clicking the X button on the Title tab.

    Description of obph1xsd.gif follows
    Description of the illustration obph1xsd.gif

  15. 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.
    Description of obph1str.gif follows
    Description of the illustration obph1str.gif

  16. 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.

  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, perform the following steps.

    1. Expand Message Types > Process WSDL - OrderBooking.wsdl > OrderBookingRequestMessage > payload in the Structure section.

    2. 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.

    3. Click Cancel.

    4. Expand Message Types > Process WSDL - OrderBooking.wsdl > OrderBookingResponseMessage > payload in the Structure section.

    5. 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.

    6. Click Cancel.

2.2.5 Validating Your Project During the Design Phase

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.

  1. Click Validate above the designer window to validate your process.

    Figure 2-1 Validating a Process

    Description of introval.gif follows
    Description of the illustration introval.gif

    If the activity correctly validates, the flag disappears.

  2. If the yellow flag remains, you still have validation errors in activities or your process design is not yet complete.

  3. 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.

2.2.6 Creating a Credit Rating Service Partner Link

Summary:

You now create a partner link for the Credit Rating service. This is the service you started when you ran ant 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.
  1. 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.

    Description of palette.gif follows
    Description of the illustration palette.gif

  2. 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.

    Description of obph1pl.gif follows
    Description of the illustration obph1pl.gif

  3. 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":

    Description of wsdlfile.gif follows
    Description of the illustration wsdlfile.gif

    Description of obph1wsdl.gif follows
    Description of the illustration obph1wsdl.gif

    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.

  4. Click OK.

  5. Select Save from the File main menu.

2.2.7 Creating Scope and Invoke Activities

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".
  1. 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.

    Description of palette2.gif follows
    Description of the illustration palette2.gif

  2. 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.

    Description of obph1dnd1.gif follows
    Description of the illustration obph1dnd1.gif

    Note that the first time your drag and drop an activity, it has a generic name such as Scope_1.

  3. Double-click the scope icon to display the Scope window.

  4. Enter GetCreditRating in the Name field of the General tab.

  5. Click OK.

  6. Click the + sign to expand the Scope activity. You now add an Invoke activity and two Assign activities to this Scope activity.

  7. Drag and drop an Invoke activity from the Component Palette section to inside the GetCreditRating Scope activity.

    Description of obph1dnd2.gif follows
    Description of the illustration obph1dnd2.gif

  8. Double-click the Invoke icon to display the Invoke window.

  9. Enter the following details:

    Field Value
    Name invokeCR
    Partner Link CreditRatingService

    The Operation (process) field is automatically filled in.

  10. Click the first icon to the right of the Input Variable field. This is the automatic variable creation icon.

    Description of autocreate.gif follows
    Description of the illustration autocreate.gif

  11. 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.

  12. Click the first icon to the right of the Output Variable field.

  13. 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.

  14. Click OK.

  15. Select Save from the File main menu.

2.2.8 Creating an Initial Assign Activity to Send a Request to the Credit Rating Service

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.
  1. Drag and drop an Assign activity from the Component Palette section to above the invokeCR Invoke activity and inside the GetCreditRating Scope activity.

    Description of obph1dnd3.gif follows
    Description of the illustration obph1dnd3.gif

  2. Double-click the assign icon to display the Assign window.

  3. Click the General tab.

  4. Enter assignCR in the Name field.

  5. Click Apply.

  6. Click the Copy Operation tab.

  7. Click Create and select Copy Operation to display the Create Copy Operation window.

    Description of obph1create.gif follows
    Description of the illustration obph1create.gif

  8. Enter the following details:

    Field Value
    From
    • Type
    Variable
    • Variables
    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
    • Type
    Variable
    • Variables
    Expand and select Variables > invokeCR_process_InputVariable > payload > ns2:ssn

    The Create Copy Operation window appears as follows:

    Description of obph1as.gif follows
    Description of the illustration obph1as.gif

  9. Click OK to close the Create Copy Operation window and the Assign window.

  10. Select Save from the File main menu.

2.2.9 Creating a Second Assign Activity to Receive a Response from the Credit Rating Service

Summary:

This Assign activity takes the response received from the Credit Rating service and places it in the comment field.
  1. Drag and drop an Assign activity from the Component Palette section to below the invokeCR Invoke activity and inside the GetCreditRating Scope activity.

    Description of obph1dnd4.gif follows
    Description of the illustration obph1dnd4.gif

  2. Double-click the assign icon to display the Assign window.

  3. Click the General tab.

  4. Enter assignRating in the Name field.

  5. Click Apply.

  6. Click the Copy Operation tab.

  7. Click Create and select Copy Operation to display the Create Copy Operation window.

  8. Enter the following details:

    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
    • Type
    Expression
    • 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
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments

  9. Click OK to close the Create Copy Operation window and the Assign window.

  10. Click the - sign to close the GetCreditRating Scope activity.

    Description of obph1collscope2.gif follows
    Description of the illustration obph1collscope2.gif

    When closed, the GetCreditRating Scope activity looks as follows:

    Description of obph1collscope.gif follows
    Description of the illustration obph1collscope.gif

  11. Select Save from the File main menu.

2.2.10 Creating a Third Assign Activity

  1. Drag and drop an Assign activity from the Component Palette section to below the GetCreditRating Scope activity and above the callbackClient activity.

    Description of obph1dnd5.gif follows
    Description of the illustration obph1dnd5.gif

  2. Double-click the assign icon to display the Assign window.

  3. Click the General tab.

  4. Enter assignOutput in the Name field.

  5. Click Apply.

  6. Click the Copy Operation tab.

  7. Click Create and select Copy Operation to display the Create Copy Operation window.

  8. Enter the following details to create a statement:

    Field Value
    From
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload
    To
    • Type
    Variable
    • Variables
    Expand and select Variables > outputVariable > payload

  9. Click OK to close the Create Copy Operation window and the Assign window.

  10. Select Save from the File main menu.

    When complete, the designer window looks as follows:

    Description of obph1.gif follows
    Description of the illustration obph1.gif

2.2.11 Validating, Compiling, and Deploying the Order Booking Process

  1. Go to the Application Navigator section.

  2. Right-click OrderBooking.

  3. 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.

    Description of obph1deploy.gif follows
    Description of the illustration obph1deploy.gif

  4. 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.

  5. Make corrections and deploy again.

2.2.12 Running the Order Booking Process

You are now ready to begin the process of applying for a new order.

  1. 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.

  2. 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.

  3. Click OrderBooking in the Deployed BPEL Processes list.

  4. 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.
    
    
  5. Click the Instances tab at the top.

  6. 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.

    Description of obph1run.gif follows
    Description of the illustration obph1run.gif

  7. Click the OrderBooking instance.

    A message appears stating the following:

    The state of this instance is Completed
    
    
  8. Click the Audit link to follow the instance execution process. The Audit link displays the following details:

    Description of obph1audit.gif follows
    Description of the illustration obph1audit.gif

  9. Click the Flow link.

  10. Click callbackClient at the bottom of the flow to see the results.

    Description of obph1flow.gif follows
    Description of the illustration obph1flow.gif

  11. 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.

2.3 Summary

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: