Skip Headers
Oracle® BPEL Process Manager Quick Start Guide
10g Release 2 (10.1.2)
B15604-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

3 Loan Process Tutorial

This tutorial describes how to design and execute a more sophisticated BPEL process than the one you created in Chapter 2, "Credit Flow Tutorial". Fault-handling, interaction with asynchronous services, parallel flows of execution, and decision making logic are all key requirements for many business flows. This tutorial enables you to design, test, debug, and manage a BPEL process that implements all of these requirements.

This tutorial contains these topics:

3.1 Loan Process Introduction

In this tutorial, you design a process that takes a loan application document from a client and returns a selected and approved loan offer. When you run this process, it retrieves a social security number that you enter into an HTML user interface and contacts the Credit Rating service to request a credit rating for the client. If a credit rating is supplied, the process sends the completed loan application to two loan providers (Star Loan and United Loan). Each provider can take some time before returning loan offers. The flow waits for both loan offers to be received before selecting the offer with the lowest interest rate to send to the client.

The process can also be designed to handle negative credit exceptions. These exceptions are made known by the credit rating service if a negative credit event is identified for the client (for example, a bankruptcy).

Figure 3-1 provides an overview of this communication:

Figure 3-1 Loan Process Tutorial Overview

Description of Figure 3-1  follows
Description of "Figure 3-1 Loan Process Tutorial Overview"

3.2 Using the Loan Process Tutorial

This tutorial contains these topics:


Note:

Save frequently to ensure that you do not lose any changes.

3.2.1 Starting Oracle BPEL Server and JDeveloper BPEL Designer

Ensure that Oracle BPEL Server and JDeveloper BPEL Designer are started. See "Starting Oracle BPEL Server and JDeveloper BPEL Designer" for instructions.

3.2.2 Starting and Testing Your Services

During this tutorial, the BPEL process that you design communicates with the Credit Rating service and the Star Loan and United Loan provider services described in "Loan Process Introduction". You must first start these services and test that they are running.

  1. Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager 10.1.2 > Developer Prompt to open up a command prompt at the Oracle_Home\integration\orabpel\samples directory.

  2. Change directories to the demos\LoanDemo subdirectory:

    cd demos\LoanDemo
    
    
  3. Enter the following command:

    obant
    
    

    This deploys and starts the required services for using this tutorial. If successful, a message similar to the following appears at the end:

    deployLoanFlowUI:all:BUILD SUCCESSFULTotal time: 1 minute 25 secondsC:\oranew\integration\orabpel\samples\demos\LoanDemo>ENDLOCAL
    
    
  4. Log into Oracle BPEL Console by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager 10.1.2 > BPEL Console.

  5. Enter bpel as the password when prompted.

    All services for this tutorial are running if the following names display in the Dashboard tab.

    • CreditRatingService

    • LoanFlow

    • StarLoan

    • TaskActionHandler

    • TaskManager

    • UnitedLoan


    See Also:

    "Connecting to Oracle BPEL Server" for instructions on creating a connection

3.2.3 Creating a Loan Process Project

You must create a project to begin. Follow these instructions to create a new Loan Process project inside the same myBPELworkspace workspace you created in "Creating a Workspace and a Project". If you have not yet created a workspace, see that section for instructions.


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 myBPELworkspace in the Applications Navigator section of JDeveloper BPEL Designer.

  2. Select New Project.

  3. Double-click BPEL Process Project in the Items window to display the BPEL Process Project window.

  4. Enter myLoanProcess in the BPEL Process Name field. All other fields default to the correct values for creating an asynchronous BPEL process.

  5. Click OK.

  6. The following sections appear. If these do not appear, click Diagram View and double-click myLoanProcess.bpel in the Applications Navigator section. See the Oracle BPEL Process Manager Developer's Guide for a description of JDeveloper BPEL Designer sections.

    Description of designerwhole.gif follows
    Description of the illustration designerwhole.gif

3.2.4 Creating the Loan Process Schema File

  1. Use an ASCII text editor to copy and paste the following syntax into a file:

    <?xml version="1.0"?>    <schema attributeFormDefault="qualified" elementFormDefault="qualified"
     targetNamespace="http://www.autoloan.com/ns/autoloan"
     xmlns="http://www.w3.org/2001/XMLSchema"
     xmlns:s1="http://www.autoloan.com/ns/autoloan">
              <element name="loanApplication" type="s1:LoanApplicationType"/>
              <element name="loanOffer" type="s1:LoanOfferType"/>
              
              <complexType name="LoanOfferType">
                  <sequence>
                    <element name="providerName" type="string"/>
                    <element name="selected" type="boolean"/>
                    <element name="approved" type="boolean"/>
                    <element name="APR" type="double"/>
                  </sequence>
              
              </complexType>
              <complexType name="LoanApplicationType">
                  <sequence>
                    <element name="SSN" type="string"/>
                    <element name="email" type="string"/>
                    <element name="customerName" type="string"/>
                    <element name="loanAmount" type="double"/>
                    <element name="carModel" type="string"/>
                    <element name="carYear" type="string"/>
                    <element name="creditRating" type="int"/>
                  </sequence>
              </complexType>
        </schema>
    
    
  2. Save the file to Oracle_Home\integration\jdev\jdev\mywork\myBPELworkspace\myLoanProcess\Loanflow.xsd.

3.2.5 Importing the Loan Process Schema File

  1. Go to the Structure section on the lower left side of JDeveloper BPEL Designer. If this section does not appear, double-click myLoanProcess.bpel in the Applications Navigator.

  2. Right-click Project Schemas.

  3. Select Import Schema to display the Import Schema window.

  4. Click the flashlight icon to access the Open window.

  5. Select Loanflow.xsd from the directory in which you saved it in Step 2 and click Open.

    The file is added to the URL field of the Import Schema window.

  6. Click OK.

    The Loanflow.xsd file now displays in both the Applications Navigator section (under myLoanProcess > Web Content > Miscellaneous Files) and the Structure section (under Project Schemas).

  7. Select and right-click Message Types in the Structure tree.

  8. Select Expand All Child Nodes.

  9. Select myLoanProcessRequestMessage > payload.

  10. Right-click payload and select Edit Message Part.

  11. Click Element and click the flashlight icon to display the Type Chooser window.

  12. Select Project Schema Files > Loanflow.xsd > loanApplication.

  13. Click OK to close the Type Chooser window and Edit Message Part window.

  14. Select myLoanProcessResponseMessage > payload.

  15. Right-click payload and select Edit Message Part.

  16. Click Element and click the flashlight icon to display the Type Chooser window.

  17. Select Project Schema Files > Loanflow.xsd > loanOffer.

  18. Click OK to close the Type Chooser window and Edit Message Part window.

  19. Select Save from the File main menu.

3.2.6 Creating and Configuring a Partner Link for the Credit Rating Service

You now create and configure a partner link for the synchronous Credit Rating service.

This section contains these tasks:


Note:

As you create and open activities such as Scope and Assign for the first time, the message Invalid Settings can appear at the top. This is because you have not yet entered details. You can ignore this message. After you enter and apply your details, the message disappears.


Note:

As you drag and drop activities, create partner links, create variables, and so on, the project files that display in the Applications Navigator section are also updated. If you want, you can click Source for the selected project file to view the syntax changes. However, do not manually edit these files.

3.2.6.1 Creating a Credit Rating Service Partner Link


Summary:

Partner links define the external services with which your BPEL process interacts. You must create a partner link for the Credit Rating service.

  1. Ensure that Process Activities is selected in the drop-down list of the Component Palette section.

  2. Drag and drop a PartnerLink activity onto the right side of JDeveloper BPEL Designer.

  3. Enter the following values to create a partner link for the Credit Rating service:


    Note:

    For the WSDL File field below, click the flashlight (the second icon from the left named WSIL Browser) to access the WSDL Chooser window shown below for automatically selecting the Credit Rating service deployed in "Starting and Testing Your Services".

    Description of wsdlchooser.gif follows
    Description of the illustration wsdlchooser.gif

    Field Value
    Name CreditRatingService
    WSDL File Access this URL by clicking the WSIL Browser flashlight icon and expanding and selecting LocalBPELServer > processes > default > CreditRatingService.

    http://localhost:9700/orabpel/default/CreditRatingService/CreditRatingService?wsdl

    See Also: "Setting the Hostname in Your Web Browser Preferences" if you receive a parsing error when attempting to add a WSDL file in the WSDL Chooser window.

    Partner Link Type CreditRatingService
    My Role Leave unspecified.
    Partner Role CreditRatingServiceProvider

  4. Click OK.

    The CreditRatingService partner link now appears on the right side of JDeveloper BPEL Designer.

    Description of partnerlink.gif follows
    Description of the illustration partnerlink.gif

3.2.6.2 Creating a Scope Activity


Summary:

You now create a Scope activity. A Scope activity consists of a collection of activities that can have their own local variables, fault handlers, and so on. A Scope activity is analogous to a { } block in a programming language.

Within this Scope activity, the client's credit rating background is identified.


  1. Go to the Component Palette section in the upper right part of JDeveloper BPEL Designer.

  2. Drag and drop a Scope activity between the receiveInput and callbackClient activities that were automatically created with your BPEL project.

  3. Double-click the Scope activity 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 GetCreditRating Scope activity.

  7. Select Save from the File main menu.

3.2.6.3 Creating an Invoke Activity Inside the Scope Activity


Summary:

You create an Invoke activity in this section. An Invoke activity enables you to specify the operation you want to invoke for the service (identified by its partner link). You can also create variables in an Invoke activity.

This Invoke activity provides the initial interaction operation between the client and the Credit Rating service.


  1. Drag and drop an Invoke activity from the Component Palette section into the GetCreditRating Scope activity.

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

  3. Enter the following details:

    Field Value
    Name invokeCR
    Partner Link CreditRatingService

    The Operation (process) field is automatically filled in.

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

  5. Click OK on the Create Variable window that appears.

    A variable named invokeCR_process_InputVariable is automatically created in the Input Variable field. This variable is automatically assigned a message type of CreditRatingServiceRequestMessage.

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

  7. Click OK on the Create Variable window that appears.

    A variable named invokeCR_process_OutputVariable is automatically created in the Output Variable field. This variable is automatically assigned a message type of CreditRatingServiceResponseMessage.

  8. Click OK.

  9. Select Save from the File main menu.

3.2.6.4 Creating an Initial Assign Activity Inside the Scope Activity


Summary:

In this section you create the first of several Assign activities in this tutorial. An Assign activity provides a method for simple data manipulation, such as copying the contents of one variable to another.

This Assign activity takes the client's social security number as input and contacts the Credit Rating service to assign a credit rating.


  1. Drag and drop an Assign activity from the Component Palette section to above the invokeCR Invoke activity and inside the Scope activity.

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

  3. Enter assignSSN in the Name field of the General tab.

  4. Click Apply.

  5. Click the Copy Rules tab.

  6. Click Create to display the Create Copy Rule window.

  7. Enter the following details:

    Field Value
    From
    • Type
    Variable
    • Variables
    Expand and select Variables > inputVariable > payload > ns1:loanApplication > ns1:SSN

    Note: 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 > invokeCR_process_InputVariable > payload > ns2:ssn

  8. Click OK to close the Create Copy Rule window and the Assign window.

  9. Select Save from the File main menu.

3.2.6.5 Creating a Second Assign Activity Inside the Scope Activity


Summary:

This Assign activity returns details about the client's assigned credit rating. If the credit rating query did not identify a bad credit history (such as a bankruptcy), the client's loan application request document is ready to be sent to the Star Loan and United Loan service providers.

  1. Drag and drop a second Assign activity from the Component Palette section to below the invokeCR Invoke activity and inside the Scope activity.

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

  3. Enter assignCreditRating in the Name field of the General tab.

  4. Click Apply.

  5. Click the Copy Rules tab.

  6. Click Create to display the Create Copy Rule window.

  7. Enter the following details:

    Field Value
    From
    • Type
    Variable
    • Variables
    Expand and select Variables > InvokeCR_process_OutputVariable > payload > ns2:rating

    Note: 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:loanApplication > ns1:creditRating

  8. Click OK to close the Create Copy Rule window and the Assign window.

    The Scope activity (when expanded) now displays the following details:

    Description of scope1.gif follows
    Description of the illustration scope1.gif

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

  10. Select Save from the File main menu.

3.2.7 Creating and Configuring Partner Links for the Asynchronous United Loan and Star Loan Services

You now create and configure partner links for the asynchronous Star Loan and United Loan Rating service loan providers.

This section contains these tasks:


Caution:

Do not include any special characters in activity or element names (such as periods). If you do include special characters, errors appear when you attempt to compile your project.

3.2.7.1 Creating Partner Links for the United Loan and Star Loan Services


Summary:

You now create partner links for the United Loan service and Star Loan service loan providers. Star Loan and United Loan are asynchronous services that support a one-way initiate operation and an asynchronous onResult callback that is invoked when a loan offer is available from each service. This can take anywhere from a few seconds to a few days or more to process. Since the loan providers can be long-running, they are implemented as asynchronous services. The BPEL process invokes them in parallel.

  1. Drag and drop a PartnerLink activity from the Component Palette section onto the right side of JDeveloper BPEL Designer.

  2. Enter the following values to create a partner link for the United Loan provider:


    Note:

    For the WSDL File field below, click the flashlight (the second icon from the left named WSIL Browser) to access the WSDL Chooser window for automatically selecting the United Loan service deployed in "Starting and Testing Your Services".

    Field Value
    Name UnitedLoanService
    WSDL File Access this URL by clicking the WSIL Browser flashlight icon and expanding and selecting LocalBPELServer > processes > default > UnitedLoan.

    http://localhost:9700/orabpel/default/UnitedLoan/UnitedLoan?wsdl

    Partner Link Type LoanService
    My Role LoanServiceRequester
    Partner Role LoanServiceProvider

  3. Click OK.

  4. Drag another PartnerLink activity from the Component Palette section. However, drop it onto the left side of JDeveloper BPEL Designer this time. This is not a requirement. However, it makes it easier to view the BPEL process interaction with the three partner links in JDeveloper BPEL Designer when you are done.

  5. Enter the following values to create a partner link for the Star Loan provider:

    Field Value
    Name StarLoanService
    WSDL File Access this URL by clicking the WSIL Browser flashlight icon and expanding and selecting LocalBPELServer > processes > default > StarLoan.

    http://localhost:9700/orabpel/default/StarLoan/StarLoan?wsdl

    Partner Link Type LoanService
    My Role LoanServiceRequester
    Partner Role LoanServiceProvider

  6. Click OK.

    The three partner links now appear as follows in JDeveloper BPEL Designer.

    Description of partnerlinksall.gif follows
    Description of the illustration partnerlinksall.gif

  7. Select Save from the File main menu.


    Summary:

    If you accidently created the Star Loan and United Loan partner links on the same side of JDeveloper BPEL Designer, right-click the StarLoanService partner link, and select Move To Opposite Swim Lane.

3.2.7.2 Creating a Second Scope Activity


Summary:

Within this Scope activity, the client's loan application document is submitted to the Star Loan and United Loan service providers. Both loan providers submit offers, of which the best offer is returned to the client.

  1. Drag and drop a second Scope activity from the Component Palette section to below the GetCreditRating Scope activity.

  2. Double-click the Scope activity.

  3. Enter GetLoanOffers in the Name field of the General tab.

  4. Click OK.

  5. Select Save from the File main menu.

3.2.7.3 Adding a Flow Activity to the Second Scope


Summary:

You now create a Flow activity into which you place Invoke and Receive activities for both the Star Loan and United Loan providers. A Flow activity is required to invoke the two loan providers in parallel. This is because they can each take an arbitrary amount of time to complete their loan processes. A Flow activity enables several actions to be taken in parallel. In this case, the Flow activity contains two parallel activities – the sequence to invoke the United Loan service and the sequence to invoke the Star Loan service.

  1. Click the + sign to expand the GetLoanOffers Scope activity.

  2. Drag and drop a Flow activity from the Component Palette section into the GetLoanOffers Scope activity.

  3. Double-click the diamond to display the Flow window.

    Description of tria.gif follows
    Description of the illustration tria.gif

  4. Enter FlowInvokeProviders.

  5. Click OK.

    JDeveloper BPEL Designer now looks as follows:

    Description of flow1.gif follows
    Description of the illustration flow1.gif

    Note that the FlowInvokeProviders name does not appear when the Flow activity is expanded. You must click the - sign to display the FlowInvokeProviders name.

  6. Select Save from the File main menu.

3.2.7.4 Creating Invoke and Receive Activities for the Star Loan Service


Summary:

This Invoke activity invokes the operation between the client's loan application document and the Star Loan service loan provider.

This Receive activity returns the loan offer results from the Star Loan service loan provider.


  1. Drag and drop an Invoke activity into the left side of the Flow activity.

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

  3. Enter the following details:

    Field Value
    Name invokeStarLoan
    Partner Link StarLoanService

    The Operation (initiate) field is automatically filled in.


    Note:

    The Output Variable field is disabled. This is because only a single input variable is received.

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

  5. Click OK on the Create Variable window that appears.

    A variable named invokeStarLoan_initiate_InputVariable is automatically created in the Input Variable field. This variable is automatically assigned a message type of LoanServiceRequestMessage.

  6. Click the flashlight (the second icon) to the right of the Input Variable field to display the Variable Chooser window.

  7. Right-click invokeStarLoan_initiate_InputVariable.

  8. Select Edit Variable.

  9. Rename it to loanApplication. You perform this task because the loanApplication variable is passed to Receive activities for both the Star Loan and United Loan services. The best offer is determined and returned to the client.

  10. Click OK to close the Edit Variable window, Variable Chooser window, and Invoke window.

  11. Drag and drop a Receive activity below the invokeStarLoan Invoke activity you just created.

  12. Double-click the Receive icon to display the Receive window.

  13. Enter the following details:

    Field Value
    Name receiveStarOffer
    Partner Link StarLoanService
    Create Instance Leave this box unchecked.

    The Operation (onResult) field is automatically filled in.

  14. Click the first icon to the right of the Variable field.

  15. Click OK on the Create Variable window that appears.

    A variable named receiveStarOffer_onResult_InputVariable is automatically created in the Variable field. This variable is automatically assigned a message type of LoanServiceResultMessage.

  16. Click OK.

  17. Select Save from the File main menu.

    The Flow activity now looks as follows:

    Description of scope2.gif follows
    Description of the illustration scope2.gif

3.2.7.5 Creating Invoke and Receive Activities for the United Loan Service


Summary:

This Invoke activity invokes the operation between the client's loan application document and the United Loan service loan provider.

This Receive activity returns the loan offer results from the United Loan service loan provider.


  1. Drag and drop an Invoke activity into the right side of the Flow activity where it says Drop Activity Here.

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

  3. Enter the following details:

    Field Value
    Name invokeUnitedLoan
    Partner Link UnitedLoanService

    The Operation (initiate) field is automatically filled in.


    Note:

    The Output Variable field is disabled. This is because only a single variable is received.

  4. Click the flashlight icon (the second icon) to the right of the Input Variable field. This displays the Variable Chooser window. We reuse the loanApplication variable for this activity.

  5. Select loanApplication.

  6. Click OK to close the Variable Chooser window and Invoke window.

  7. Drag and drop a Receive activity below the invokeUnitedLoan Invoke activity you just created.

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

  9. Enter the following details:

    Field Value
    Name receiveUnitedOffer
    Partner Link UnitedLoanService
    Create Instance Leave this box unchecked.

    The Operation (onResult) field is automatically filled in.

  10. Click the first icon to the right of the Variable field.

  11. Click OK on the Create Variable window that appears.

    A variable named receiveUnitedOffer_onResult_InputVariable is automatically created in the Variable field. This variable is automatically assigned a message type of LoanServiceResultMessage.

  12. Click OK.

  13. Select Save from the File main menu.

    The Flow activity now displays the following details. This activity passes the loan application document as an input variable to the initiate operations for the United Loan and Star Loan services. These initiate operations return immediately, but the next activity, the Receive activity for the onResult callback, waits until the service has called back with a loan offer.

    Description of scope6.gif follows
    Description of the illustration scope6.gif


Summary:

A dehydration point is established between the Invoke and Receive activities. Dehydration enables long-running, asynchronous flows to be automatically maintained in a database while they wait for asynchronous callbacks. This enables flows to be reliably and persistently stored in a database, along with their current state information, whenever they are waiting for asynchronous events.

BPEL also enables support for correlating asynchronous messages so that asynchronous callbacks can locate the appropriate waiting process instance. By default, WS-Addressing, which uses simple object access protocol (SOAP) message headers for correlation of asynchronous messages, is used for message content correlation with the correct instance.


3.2.7.6 Creating an Assign Activity


Summary:

This Assign activity takes the client's loan application document and sends it to the Star Loan and United Loan service loan providers.

  1. Drag and drop an Assign activity from the Component Palette section inside the GetLoanOffers Scope activity and above the Flow activity (above the diamond).

  2. Double-click the Assign activity.

  3. Enter initializeLoanApplication in the Name field of the General tab.

  4. Click Apply.

  5. Click the Copy Rules tab.

  6. Click Create to display the Create Copy Rule window.

  7. Enter the following details:

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

  8. Click OK to close the Create Copy Rule window and the Assign window.

  9. Click all - signs to close the Flow activity and Scope activity. When all are closed, your BPEL process flow displays the following details:

    Description of scope4.gif follows
    Description of the illustration scope4.gif

  10. Select Save from the File main menu.

3.2.8 Adding Offer Decision Making Logic to the Loan Process


Summary:

The Flow activity enables your flow to gather both loan offers at the same time, but does not compare any of the offers. To compare the two offers and make decisions based on that comparison, the BPEL flow requires a Switch activity. A Switch activity includes two branches: <case> and <otherwise>. The first branch is executed if a defined condition (inside the <case> branch) is met. If it is not met, the <otherwise> branch is executed.

You now add a Switch activity to the GetLoanOffers Scope activity.

  1. Click the + sign to expand the GetLoanOffers Scope activity.

  2. Drag and drop a Switch activity from the Component Palette section into the GetLoanOffers Scope activity and below the FlowInvokeProviders Flow activity.

  3. Double-click the question mark for the Switch activity to display the Switch window.

  4. Enter GetBestOffer in the Name field.

  5. Click OK.

  6. Double-click <case> to display the Switch Case window.

  7. Press Ctrl and then the space bar in the Expression field to display a list for selecting (double-clicking) the following syntax. Edit 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.

    bpws:getVariableData('receiveStarOffer_onResult_InputVariable','payload','/ns1:loanOffer/ns1:APR') > bpws:getVariableData('receiveUnitedOffer_onResult_InputVariable','payload','/ns1:loanOffer/ns1:APR')
    
    
  8. Click OK.

    Note that the syntax you added does not explicitly display when you view the <case> icon in the flow. (See Step 24.) If you want to view this syntax, double-click <case>. The syntax you entered displays in the Expression field.

  9. Drag and drop an Assign activity from the Component Palette section into the <case> section of this Switch activity.


    Summary:

    This Assign activity takes the United Loan offer and, if it is the best offer, submits it to the client. The syntax you defined in the Expression field in Step 7 determines the best offer.

  10. Double-click the Assign activity.

  11. Enter PickUnited in the Name field of the General tab.

  12. Click Apply.

  13. Click the Copy Rules tab.

  14. Click Create to display the Create Copy Rule window.

  15. Enter the following details:

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

  16. Click OK to close the Create Copy Rule window and the Assign window.

  17. Drag and drop an Assign activity from the Component Palette section into the <otherwise> section of this Switch activity.


    Summary:

    This Assign activity takes the Star Loan offer and, if it is the best offer, submits it to the client. The syntax you defined in the Expression field in Step 7 determines the best offer.

  18. Double-click the Assign activity.

  19. Enter PickStar in the Name field of the General tab.

  20. Click Apply.

  21. Click the Copy Rules tab.

  22. Click Create to display the Create Copy Rule window.

  23. Enter the following details:

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

  24. Click OK to close the Create Copy Rule window and the Assign window.

    The Switch activity displays the following details:

    Description of scope5.gif follows
    Description of the illustration scope5.gif

  25. Select Save from the File main menu.

    You have now completed the loan process design and are ready to proceed to the validation, compilation, and deployment tasks described in the following section.

3.2.9 Validating, Compiling, and Deploying the Loan Process

You are now ready to deploy your BPEL process.

  1. Go to the Applications Navigator section.

  2. Right-click myLoanProcess.

  3. Select Deploy > LocalBPELServer > Deploy to default domain.

  4. Enter bpel when prompted for the domain password.

  5. Click OK.

    This compiles the BPEL process. Review the bottom of the window for any errors. If there are no errors, the following message appears:

    [3:43:31 PM] Successful compilation: 0 errors, 0 warnings.
    Deploying to http://localhost:9700 domain: default. Please wait ...
                bpel_myLoanProcess_1.0.jar deployed successfully.
    
    
  6. If there are errors, click BPEL Validation Errors to display details about the type and location of the error.

  7. Make corrections and deploy again.

3.2.10 Running the Loan Process

You are now ready to begin the process of applying for and receiving a loan offer.

  1. Log into Oracle BPEL Console by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager 10.1.2 > BPEL Console.

  2. Enter bpel as the password when prompted.

    The Dashboard tab of Oracle BPEL Console appears. These are the services that you started and verified in Step 5 of "Starting and Testing Your Services". Note that your BPEL process, myLoanProcess, now appears in the Deployed BPEL Processes list.

    Description of dashboard.gif follows
    Description of the illustration dashboard.gif

  3. Click myLoanProcess in the Deployed BPEL Processes list.

    The loan application form appears. Note that the form includes a social security number field. At the beginning of the execution of this process, the social security number you enter is retrieved and the Credit Rating service is contacted to request a credit rating for you.

  4. Complete the loan application form. Ensure that you enter a social security number that does not begin with zero in the SSN field of the HTML Form and click Post XML Message.

    Description of LoanForm.gif follows
    Description of the illustration LoanForm.gif

  5. Go to the following URL for the Star Loan service loan provider to enter an APR value:

    http://localhost:9700/StarLoanUI
    
    

    The loan approval typically takes several minutes to display. Refresh as necessary.

    Description of starloan.gif follows
    Description of the illustration starloan.gif

  6. Click Assign APR Task.

  7. Enter an APR value that is more than 5.75% or less than 5.7% in the APR field.

  8. Click Approve.

    The following message appears:

    Assign APR Task has been completed
    
    
  9. Return to Oracle BPEL Console.

  10. Click the Instances tab to access details about this running process instance.

  11. Click the latest instance of myLoanProcess in the Instance column.

    Description of instance.gif follows
    Description of the illustration instance.gif

    A message indicates that the state of the instance is completed.

  12. Click the Flow link.

    A visual representation of the history of this process instance flow appears. This represents a view of the current state and history of the execution of this process flow instance. You can select activities to view details.

  13. Scroll through the flow.

    Description of Flow1ra.gif follows
    Description of the illustration Flow1ra.gif

  14. Continue scrolling and click the callbackClient activity at the end of the flow to see the results of the loan offer, including the best credit rating returned by the Credit Rating service to the client.

    Description of flowactivity.gif follows
    Description of the illustration flowactivity.gif

You have now completed running the loan process. You can continue to explore the features of Oracle BPEL Console.

3.2.11 Adding Error Handling Capabilities to the Loan Process (Optional)

Now that you have designed, validated, compiled, deployed, and run a process, you can add optional error handling functionality to handle rejections (for example, due to a bankruptcy).

This section contains these tasks:

3.2.11.1 Creating a Fault Handling Error Variable


Summary:

You create fault handling to catch and manage exceptions identified by the credit rating service. Fault handlers are associated with a particular Scope activity and faults encountered within a scope are passed up to this enclosing Scope activity.

  1. Go to the Structure section of JDeveloper BPEL Designer.

  2. Select Variables > Process > Variables.

  3. Right-click Variables and select Create Variable to display the Create Variable window.

  4. Enter crError in the Name field.

  5. Select Message Type and click the flashlight to display the Type Chooser window.

  6. Select Message Types > Partner Links > CreditRatingService > CreditRatingService > Message Types > CreditRatingServiceFaultMessage.

  7. Click OK to close the Type Chooser window and Create Variable window.

  8. Select Save from the File main menu.

3.2.11.2 Creating a Catch Branch in the GetCreditRating Scope Activity

  1. Click the + sign to expand the GetCreditRating Scope activity.

  2. Click Add Catch Branch near the top of the icons (fourth icon) on the left side of GetCreditRating.

    Description of addcatch.gif follows
    Description of the illustration addcatch.gif

    A new box displays to the right with an exclamation point and the words Drop Activity Here.

    Description of catchexpand.gif follows
    Description of the illustration catchexpand.gif

  3. Double-click the exclamation point inside the new box to display the Catch window.

  4. Enter the following details. Note that you assign the crError variable that you previously created.

    Field Description
    Namespace URI http://services.otn.com

    Note: This URI is the Credit Rating service's namespace. If you want to see where this namespace URI comes from, perform the following steps:

    1. Copy the URI for the Credit Rating service WSDL File field entered in Step 3.

    2. Paste this value into a Web browser.

    3. View the targetnamespace element value in the URI that appears.

    Local Part NegativeCredit

    Note: This is the fault name element value that displays in the above URI.

    Fault Variable crError

  5. Click OK.

  6. Select Save from the File main menu.

3.2.11.3 Creating an Assign Activity Inside the Catch Branch of the Scope Activity


Summary:

The client initially provided a social security number to the Credit Rating service for a credit check to occur. If a bad credit history is identified or the social security number is invalid, this Assign activity notifies the client of the loan offer rejection. The entire loan application process is terminated, and the client's loan application document is never submitted to the Star Loan and United Loan service loan providers.

  1. Drag and drop an Assign activity from the Component Palette section into the ns2:NegativeCredit Catch branch you just created. Note that ns2: automatically appears.

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

  3. Enter RejectApplication in the Name field of the General tab.

  4. Click Apply.

  5. Click the Copy Rules tab.

  6. Click Create to display the Create Copy Rule window. You now create three fault handling rules.

  7. Enter the following values:


    Note:

    If you are entering an expression, you can press Ctrl and then the space bar in the Expression field instead of manually entering details. 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.

    Field Value
    From
    • Type
    Expression
    • Expression
    string('None - rejected because of bad credit')
    To
    • Type
    Variable
    • Variables
    Expand and select Variables > outputVariable > payload > ns1:loanOffer > ns1:providerName

    Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear.


  8. Click OK.

  9. Repeat Step 6 through Step 8 to add a second copy expression for the Assign activity with the following values:

    Field Value
    From
    • Type
    Expression
    • Expression
    false()
    To
    • Type
    Variable
    • Variables
    Expand and select Variables > outputVariable > payload > ns1:loanOffer > ns1:selected

    Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear.


  10. Click OK.

  11. Repeat Step 6 through Step 8 to add a third copy expression to the Assign activity with the following values:

    Field Value
    From
    • Type
    Expression
    • Expression
    false()
    To
    • Type
    Variable
    • Variables
    outputVariable > payload > ns1:loanOffer > ns1:approved

    Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear.


  12. Click OK to close the window.

    The Assign activity now displays the copy rules.

    Description of copyrules.gif follows
    Description of the illustration copyrules.gif

  13. Click OK.

  14. Select Save from the File main menu.

3.2.11.4 Creating an Invoke Activity Inside the Catch Branch of the Scope Activity

  1. Drag and drop an Invoke activity from the Component Palette section to below the RejectApplication Assign activity you just created.

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

  3. Enter the following details:

    Field Value
    Name BadCreditInvokeClient
    Partner Link client
    Input Variable outputVariable

    Note: Click the flashlight icon (the second icon to the right of this field) to access the Variable Chooser window for selecting this variable. Then, click OK.


    The Operation (onResult) field is automatically filled in.


    Note:

    The Output Variable field is disabled. This is because only a single input variable is received.

  4. Click OK.

  5. Select Save from the File main menu.

3.2.11.5 Creating a Terminate Activity Inside the Catch Branch of the Scope Activity


Summary:

A Terminate activity enables you to end the fault handling tasks in the Catch branch. If a bad credit history is identified or the social security number is invalid, the entire loan application process is terminated, and the client's loan application document is never submitted to the Star Loan and United Loan service loan providers. Entering a social security number that begins with zero in the SSN field of the HTML Form executes this bad credit condition.

  1. Drag and drop a Terminate activity from the Component Palette section to below the BadCreditInvokeClient Invoke activity you just created.

  2. Double-click the Terminate activity to display the Terminate window.

  3. Name it terminateNegativeCredit.

  4. Click OK.

    The Catch branch now displays the following activities.

    Description of catchall.gif follows
    Description of the illustration catchall.gif

  5. Click the - sign to close the ns2:NegativeCredit Catch branch.

  6. Select Save from the File main menu.

  7. See section "Validating, Compiling, and Deploying the Loan Process" to run the loan process again with error handling functionality. Note that since you are deploying myLoanProcess again, the Deploy Properties window appears. Increment the version number to start a new version of myLoanProcess (for example, enter 1.1). This means you have two myLoanProcess versions running: the one you previous deployed and ran, and this new one that tests the fault handling logic.

    When you complete the loan application form, ensure that you enter a social security number beginning with zero in the SSN field of the HTML Form and click Post XML Message. This action activates the fault handling logic.