Skip Headers
Oracle® Fusion Middleware Tutorial for Running and Building an Application with Oracle SOA Suite
11g Release 1 (11.1.1)

Part Number E10275-02
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

5 Creating the First Half of the OrderProcessor BPEL Process

This chapter describes how to create the first half of the OrderProcessor BPEL process for the OrderBookingComposite composite. This chapter assumes you have performed all the tasks from Chapter 3 through Chapter 4.

This chapter contains the following sections:

5.1 Overview of Tasks for Creating the First Half of OrderProcessor

Table 5-1 lists and describes the tasks for creating the first half of the OrderProcessor BPEL process for the OrderBookingComposite composite.

Table 5-1 Tasks for Creating the First Half of the OrderProcessor BPEL Process for OrderBookingComposite

Task Description See

Copy Services Used by the OrderProcessor BPEL Process

Copy the service definitions you reference later during the modification of the OrderProcessor BPEL process.

Section 5.2

Add the StoreFrontService Service

Reference the StoreFrontService service.

Section 5.3

Wire the OrderProcessor BPEL Process to the StoreFrontService Service

Connect StoreFrontService to the OrderProcessor BPEL process.

Section 5.4

Create the gOrderInfoVariable Variable

Create variable gOrderInfoVariable as input for when an order is placed. To create this variable, you create it as an entity variable.

Section 5.5

Create the Scope_RetrieveOrder Scope

Create the Scope_RetrieveOrder scope to obtain the order ID using the gOrderInfoVariable entity variable.

Section 5.6

Create the Scope_RetrieveCustomerForOrder Scope

Create the Scope_RetrieveCustomerForOrder scope to call the StoreFrontService service to retrieve customer information.

Section 5.7

Create CreditCardAuthorizationService Service

Reference the CreditCardAuthorizationService service, which checks whether the customer's credit card is valid.

Section 5.8

Create the Scope_AuthorizeCreditCard Scope

Create the Scope_AuthorizeCreditCard scope to initiate the CreditCardAuthorizationService service to retrieve customer information.

Section 5.9

Create Catch Branches for the Scope_AuthorizeCreditCard Scope

Add catch branches to the Scope_AuthorizeCreditCard scope for orders in which the credit card number is not provided or the credit type is not valid.

Section 5.10

Create the RequiresApprovalRule Business Rule

Create a business rule activity to specify the RequiresApprovalRule business rule. This rule specifies that if the order total is $2,000 or more, then a manager's approval is required.

Another activity uses the output from the business rule to either automatically approve the order or use a human task to obtain manager approval.

Section 5.11

Create the Switch_ApprovalRequired Switch to the Scope_CheckApprovalLimit Scope

For an order that requires manual approval because the order total is $2,000 or more, you create the SwitchApprovalRequired switch in the ScopeCheckApprovalLimit scope with a <case> branch that passes control to the ApprovalHumanTask human task activity. This human task enables a manager to approve or reject the orders. This switch does not apply to orders that do not require manual approval.

Section 5.12


5.2 Copying Services Used by the OrderProcessor BPEL Process

Copy the service definitions you reference later during the modification of the OrderProcessor BPEL process:

  1. Copy directory services from DEMO_DOWNLOAD_HOME\CompositeServices\OrderBookingComposite to directory MY_FOD_HOME\CompositeServices\OrderBookingComposite.

  2. In the Application Navigator, select OrderBookingComposite and then click the Refresh icon.

    The OrderBookingComposite folder in Oracle JDeveloper updates with the services folder.

    Description of services.gif follows
    Description of the illustration services.gif

5.3 Adding the StoreFrontService Service

The StoreFrontService service contains order and customer information. Perform the following tasks to reference this synchronous service:

5.3.1 Task 1: Copy the WSDL Needed for StoreFrontService

To copy the WSDL for the StoreFrontService service:

  1. Copy StoreFrontServiceRef.wsdl from DEMO_DOWNLOAD_HOME\CompositeServices\OrderBookingComposite to directory MY_FOD_HOME\CompositeServices\OrderBookingComposite.

  2. In the Application Navigator, select OrderBookingComposite and then click the Refresh icon.

5.3.2 Task 2: Create a Web Service for StoreFrontService

To create a Web service for the StoreFrontService service:

  1. Click the composite.xml tab to view the SOA Composite Editor again.

  2. From the Component Palette, drag a Web Service from the Service Adapters list into the right swim lane (External References) of the SOA Composite Editor.

    Description of storefrontserv.gif follows
    Description of the illustration storefrontserv.gif

    The Create Web Service dialog appears.

    Description of storefront.gif follows
    Description of the illustration storefront.gif

  3. Enter and select the following values:

    Element Value
    Name StoreFrontService
    Type Reference
    WSDL URL Click the Find existing WSDLs icon and select StoreFrontServceRef.wsdl from MY_FOD_HOME\OrderBookingComposite

  4. Accept the other defaults, and then click OK.

    The StoreFrontService service displays in the SOA Composite Editor.

    Description of composite2.gif follows
    Description of the illustration composite2.gif

    If you receive an error, then it is likely you did not add the BC4J Runtime Service library the OrderBookingComposite project. See Section 4.3.3 to add the library.

5.4 Wiring the OrderProcessor BPEL Process to the StoreFrontService Service

To wire (connect) the StoreFrontService service to the OrderProcessor BPEL service component:

  1. Drag a wire from the OrderProcessor BPEL process interface to the StoreFrontService reference handle.

    Description of wire.gif follows
    Description of the illustration wire.gif

  2. Click Source at the bottom of the visual editor to review the wiring:

    <wire>
      <source.uri>OrderProcessor/StoreFrontService</source.uri>
      <target.uri>StoreFrontService</target.uri>
    </wire>
    
  3. Click Design at the bottom of the visual editor.

  4. Click the OrderProcessor.bpel tab to view the BPEL process again.

    The StoreFrontService service displays in the BPEL Designer.

    Description of orderprocessor2.gif follows
    Description of the illustration orderprocessor2.gif

  5. Select Save All from the File main menu to save your work.

5.5 Creating the gOrderInfoVariable Variable

In this task, you create variable gOrderInfoVariable as input for when an order is placed. The letter g is used to distinguish this variable as a global variable that can be used throughout the BPEL process. This tutorial requests that you create global variables with a letter g prefix and local variables for individual scopes with a letter l prefix. You can use a local variable only within a scope.

In previous releases, variables and messages exchanged within a BPEL business process were disconnected payload (a snapshot of data returned by a Web service) placed into an XML structure. In some cases, the user required this type of fit. In other cases, this fit presented challenges.

For this release, the entity variable can be used with an Oracle ADF Business Component data provider service using SDO-based data.

To create an entity variable for the purchase order ID and select the StoreFrontService as a partner link to invoke the Oracle ADF Business Component application:

  1. In the canvas workspace for the OrderProcessor BPEL process, click the Variables icon.

    Description of variable.gif follows
    Description of the illustration variable.gif

    The Variables dialog displays.

  2. Click the Create icon to add a variable.

    The Create Variable dialog displays.

  3. In the Name field, enter gOrderInfoVariable. Use the letter g to distinguish this variable as a global variable that can be used throughout the process.

  4. In the Type section, select Element and then select the Search icon to the right of the Element field.

    The Type Chooser dialog appears with a list of available services.

  5. Expand Project Schema Files > OrderInfoVOSDO.xsd > orderInfoVOSDO.

    OrderId represents the order in the Oracle ADF Business Component of the StoreFrontService.

    Description of orderid.gif follows
    Description of the illustration orderid.gif

  6. Select orderInfoVOSDO, and then click OK.

  7. In the Create Variable dialog, click the Entity Variable check box and select the Search icon to the right of the Partner Link field.

    The Partner Link Chooser window displays.

  8. Expand Process > Partner Links and select StoreFrontService, and then click OK.

    The Create Variable dialog shows the element and service information.

    Description of entityvar.gif follows
    Description of the illustration entityvar.gif

  9. Click OK in the Create Variable dialog.

    The Variables dialog updates with the gOrderInfoVariable entity variable.

    Description of entityvar2.gif follows
    Description of the illustration entityvar2.gif

  10. Click OK in the Variables dialog.

5.6 Creating the Scope_RetrieveOrder Scope

The Scope_RetrieveOrder scope uses a bind entity activity to obtain the order ID using the gOrderInfoVariable entity variable.

Figure 5-1 Scope_RetrieveOrder

Description of Figure 5-1 follows
Description of "Figure 5-1 Scope_RetrieveOrder"

A scope activity does not actually execute or do anything, it simply holds other activities. Scopes are analogous to curly braces in Java. You can use them to break up your process into logical chunks.

To create this scope, perform these tasks:

5.6.1 Task 1: Add the Scope_RetrieveOrder Scope

To create the Scope_RetrieveOrder scope:

  1. From the Component Palette, drag a Scope activity below the receiveInput activity.

    Description of retrieve.gif follows
    Description of the illustration retrieve.gif

  2. Rename this activity by double-clicking the name underneath the icon. Do not double-click the activity icon itself.

  3. In the edit field, change the name to Scope_RetrieveOrder.

  4. Click the Expand (+) icon to expand the Scope_RetrieveOrder scope.

5.6.2 Task 2: Create findOrderById Bind Entity Activity

To create a key to point to the data in the Oracle ADF Business Component data provider service:

  1. From the Component Palette, drag a Bind Entity activity into the Scope_RetrieveOrder scope.

  2. Double-click the Bind Entity activity.

    The Bind Entity window displays.

    Description of bindentity.gif follows
    Description of the illustration bindentity.gif

  3. In the Name field, enter findOrderById.

  4. Click the Search icon next to the Entity Variable field.

    The Browse Variables dialog appears.

  5. Select the gOrderInfoVariable variable you created in Section 5.5, and then click OK.

    Description of entityvar3.gif follows
    Description of the illustration entityvar3.gif

  6. In the Unique Keys section of the Bind Entity window, click the Create icon to create a key for retrieving the order ID from the database.

    The Specify Key dialog appears.

  7. Configure the following settings to define the binding key:

    Element Procedure
    Key Local Part
    1. Click the Browse Entity Variable icon. It is the icon to the right of the Key Local Part field.

      The Browse Entity Key dialog appears.

    2. Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select element ns4:OrderId. Do no select the OrderId key. The namespace number values (for example, ns1, ns2) can vary.

    3. Click OK.

    Key Namespace URI Leave the default for the namespace URI for the key.
    Key Value
    1. Click the Expression Builder icon.

      The Expression Builder dialog appears.

    2. In the BPEL Variable section, expand Variables > inputVariable > payload > ns4:WarehouseRequest and select ns4:orderId.

    3. Click Insert Into Expression.

    4. Click OK in the Specify Key dialog.


  8. Click OK to close the Specify Key dialog.

    A name-pair value appears in the Unique Keys table.

    Description of bindentity2.gif follows
    Description of the illustration bindentity2.gif

  9. Click OK to close the Bind Entity window.

    When the bind entity activity is executed at run time, the gOrderInfoVariable entity variable is ready to be used. Otherwise, a run-time fault results.

  10. Click the Collapse (-) icon to minimize the Scope_RetrieveOrder scope.

5.7 Creating the Scope_RetrieveCustomerForOrder Scope

The Scope_RetrieveCustomerForOrder scope calls the StoreFrontService service to retrieve customer information. It assigns the customer ID from global variable gOrderInfoVariable to local variable lFindCustomerInfo_InputVariable for the scope. The scope then uses an invoke activity to call the StoreFrontService service. The invoke activity provides the lFindCustomerInfo_InputVariable variable as input to the service, and the StoreFrontService service returns information about the customer, such as the customer name and email address, back to the BPEL process through the gCustomerInfoVariable global variable.

Figure 5-2 Scope_RetrieveCustomerForOrder

Description of Figure 5-2 follows
Description of "Figure 5-2 Scope_RetrieveCustomerForOrder"

To create this scope, perform the following tasks:

5.7.1 Task 1: Add the Scope_RetrieveCustomerForOrder Scope

To create the Scope_RetrieveCustomerForOrder scope:

  1. From the Component Palette, drag a Scope activity below the Scope_RetrieveOrder activity.

  2. Rename this activity by double-clicking the name underneath the icon. Do not double-click the activity icon itself.

  3. In the edit field, change the name to Scope_RetrieveCustomerForOrder.

  4. Click the Expand (+) icon to expand the Scope_RetrieveCustomerForOrder scope.

5.7.2 Task 2: Create the InvokeCustomerService Activity

An invoke activity invokes a service and passes it data, and in this case, wait for a response from the service with the return data. To call the StoreFrontService service, you create an invoke activity:

  1. From the Component Palette, drag an Invoke activity into the Scope_RetrieveCustomerForOrder scope.

  2. Rename this activity by double-clicking name underneath the icon. Do not double-click the invoke icon itself.

  3. In the edit field, change the name to InvokeFindCustomer.

  4. Drag the mouse from the right side of InvokeFindCustomer to the StoreFrontService partner link.

    Description of customerservice1.gif follows
    Description of the illustration customerservice1.gif

    The Edit Invoke dialog appears and is automatically filled in with the following information:

    Element Value
    Name InvokeFindCustomer
    Partner Link StoreFrontService
    Operation findCustomerInfoV01

    You change the value for this field in the next step.


  5. In the Operation field, change the selection to findCustomerInfoVO1CustomerInfoVOCriteria.

  6. Click the Automatically Create Input Variable icon. It is the first icon to the right of the Input Variable field.

    The Create Variable dialog appears for the input variable. This variable provides input data to the StoreFrontService service, namely the ID of the customer.

  7. Enter and select the following values:

    Element Value
    Name lFindCustomerInfo_InputVariable

    Use the letter l to distinguish this variable as a local variable that can be used only within this scope. This tutorial requests that you create global variables with a letter g prefix and local variables for individual scopes with a letter l prefix. You can use a local variable only within a scope.

    Global Variable/Local Variable Local Variable, because this variable is not needed for other scopes in the process

  8. Click OK to close the Create Variable dialog.

    The Edit Invoke dialog populates with the variable in the Input Variable field.

  9. Click the Automatically Create Output Variable icon. It is the first icon to the right of the Output Variable field.

    The Create Variable dialog appears for the output variable. This variable provides output data to the StoreFrontService service, such as the customer's ID, name, contact information, and membership information.

  10. Enter and select the following values:

    Element Value
    Name gCustomerInfoVariable

    Use the letter g to distinguish this variable as a global variable that can be used throughout the process.

    Global Variable/Local Variable Global Variable, because other scopes in the process use this variable

  11. Click OK to close the Create Variable dialog.

    The Edit Invoke dialog populates with the variable in the Output Variable field.

  12. In the Edit Invoke dialog, click OK to save the variable settings.

5.7.3 Task 3: Create the AssignCustomerId Activity

In this task, you create an assign activity to take the customer ID and send it to the input variable for the StoreFrontService service.

  1. From the Component Palette, drag an Assign activity above the InvokeFindCustomer invoke activity.

  2. Rename this activity by double-clicking name underneath the icon. Do not double-click the assign icon itself.

  3. In the edit field, enter AssignCustomerId.

  4. Double-click the AssignCustomerId activity.

    The Assign dialog displays.

  5. From the dropdown list, select Copy Operation:

    Description of copyoperat.gif follows
    Description of the illustration copyoperat.gif

    The Create Copy Operation dialog appears.

  6. On the From side, expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO > ns4:CustomerId. The namespace number values (for example, ns1, ns2) can vary.

  7. On the To side, expand Scope - Scope_RetrieveCustomerForOrder > Variables > lFindCustomerInfo_InputVariable > parameters > ns4:findCustomerInfoVO1CustomerInfoVOCriteria and select ns4:CustId. The namespace number value can vary.

  8. Click OK to close the Create Copy Operation dialog.

    The Copy Operation tab in the Assign updates to show the operation you created.

    Description of copyoperat2.gif follows
    Description of the illustration copyoperat2.gif

  9. In the Assign dialog, click OK.

  10. Click the Collapse (-) icon to minimize the Scope_RetrieveCustomerForOrder scope.

  11. Select Save All from the File main menu to save your work.

5.7.4 Task 4: Deploy the OrderBookingComposite Composite

To deploy the OrderBookingComposite composite:

  1. In the Application Navigator, right-click OrderBookingComposite and select Deploy > OrderBookingComposite > to MyAppServerConnection. You created the MyAppServerConnection connection in Section 1.2.4, "Task 4: Create a Connection to an Oracle WebLogic Server."

    The SOA Deployment Configuration Dialog displays.

  2. Accept the default settings and click OK.

  3. When prompted with the Authorization Request dialog, enter weblogic in the Username field and the password in the Password field.

    In SOA - Log, a series of validations display, followed by:

    BUILD SUCCESSFUL
    Total time: nn seconds
    

5.7.5 Task 5: Deploy the OrderSDOComposite Composite

To initiate a test instance of the OrderBookingComposite composite, you must deploy a service using the StoreFrontService.wsdl. If you performed the tasks in Section 2.1.2 and have the Store Font module currently running, then you can use it to test the OrderBookingComposite composite. You can proceed to Section 5.7.6, "Task 6: Initiate a Test Instance for the OrderBookingComposite Composite." If you do not have the Store Front module currently running, then deploy the OrderSDOComposite composite, available from the sample application.

To deploy the OrderSDOComposite composite:

  1. In the Application Navigator, select WebLogicFusionOrderDemo for the sample application in the DEMO_DOWNLOAD_HOME directory.

  2. In the Application Navigator, right-click OrderSDOComposite and select Deploy > OrderSDOComposite > to MyAppServerConnection.

    The SOA Deployment Configuration Dialog displays.

  3. Accept the default settings and click OK.

  4. When prompted with the Authorization Request dialog, enter weblogic in the Username field and the password in the Password field.

    In SOA - Log, a series of validations display, followed by:

    BUILD SUCCESSFUL
    Total time: nn seconds
    
  5. In the Application Navigator, select WebLogicFusionOrderDemo for the application you currently building in the MY_FOD_HOME directory.

5.7.6 Task 6: Initiate a Test Instance for the OrderBookingComposite Composite

In this task, you can initiate a test instance of the OrderBookingComposite composite in one of two ways:

  • You can use the Store Front module by submitting an order, similarly to the first order described in Section 2.2 and monitor the order instance described in Section 2.4. The order should progress through the Scope_RetrieveCustomerForOrder scope.

  • Use the OrderSDOComposite composite by initiating a test instance of the OrderSDOComposite composite from the Test Web Service page in Fusion Middleware Control. Use the steps described next.

To initiate a test instance of the OrderSDOComposite composite:

  1. Access the Test Web Service page in Fusion Middleware Control through the following options:

    From the SOA Infrastructure Menu... From the SOA Folder in the Navigator... From the SOA Composite Menu...
    1. Select Home.
    2. Select the Deployed Composites tab.

    3. In the Composite section, select OrderBookingComposite.

    4. At the top of the page, click Test.

    1. Under soa-infra, select OrderBookingComposite.
    2. At the top of the page, click Test.

    Select Test Service > orderprocessor_client_ep.

  2. In the Inputs Arguments section of the Test Web Service page, in the orderID field, enter an ID under 1000.

  3. Click Test Web Service.

    The test results appear in the Response tab upon completion.

  4. Click Launch Message Flow Trace to access the flow trace of the instance.

  5. In the Flow Trace window, in the Trace section, click the OrderProcessor BPEL process.

  6. In the Flow Trace window for the instance, click the Flow tab.

  7. Click the various activities to see the flow through the Scope_RetrieveCustomerForOrder scope.

  8. Click X or Close to the dismiss the Activity Details dialog.

  9. Close the Flow Trace window.

5.8 Creating CreditCardAuthorizationService Service

The CreditAuthorizationService service checks whether the customer's credit card is valid. You create it by creating a Web service based on a WSDL from the FusionOrderDemo_R1.zip.

Later, in Section 5.8, "Creating CreditCardAuthorizationService Service," you create a scope for the OrderProcessor BPEL process to call this service.

5.8.1 Task 1: Copy WSDL File Needed for CreditCardAuthorizationService

Copy CreditCardAuthorizationService.wsdl from directory DEMO_DOWNLOAD_HOME\CompositeServices\OrderBookingComposite to directory MY_FOD_HOME\CompositeServices\OrderBookingComposite.

5.8.2 Task 2: Create a Web Service for CreditCardAuthorizationService

In Section 5.3.2, "Task 2: Create a Web Service for StoreFrontService," you created a reference to the Web service from the SOA Composite Editor. In this task, you create the reference from the BPEL Designer.

To create a Web service for the CreditCardAuthorizationService service:

  1. From the Component Palette, drag a Partner Link (Web Service/Adapter) from the BPEL Services list into the right swim lane of the BPEL Designer.

    The Create Partner Link dialog appears.

  2. Enter and select the following values:

    Element Value
    Name CreditCardAuthorizationService
    WSDL file Browse and select CreditAuthorizationService.wsdl from MY_FOD_HOME\OrderBookingComposite.
    Partner Link Type Leave the default as CreditCardAuthorizationService.
    Partner Role CreditAuthorizationPort
    My Role Leave the default as Not Specified, since this service is synchronous

  3. Click OK.

    The CreditCardAuthorizationService service displays in the right swim lane.

    If you click the composite.xml tab, you can see the CreditCardAuthorizationService service automatically propagates to the SOA Composite Editor.

    Description of composite3.gif follows
    Description of the illustration composite3.gif

5.9 Creating the Scope_AuthorizeCreditCard Scope

The Scope_AuthorizeCreditCard scope calls the CreditCardAuthorizationService service to retrieve customer information. It assigns the order total, credit card type, and the account number from global variable gOrderInfoVariable to local variable lCreditCardInput for the scope. The scope then uses an invoke activity to call the CreditCardAuthorizationService service. The invoke activity provides the lCreditCardInput variable as input to the service, and the CreditCardAuthorizationService service returns the status back to the BPEL process through the lCreditCardCardOutput local variable. This switch activity checks the results of the credit card validation.

Figure 5-3 Scope_AuthorizeCreditCard

Description of Figure 5-3 follows
Description of "Figure 5-3 Scope_AuthorizeCreditCard"

To create this scope, perform the following tasks:

5.9.1 Task 1: Add the Scope_AuthorizeCreditCard Scope

To create the Scope_AuthorizeCreditCard scope:

  1. Back in the OrderProcessor.bpel tab, from the Component Palette, drag a Scope activity from the Component Palette section below the Scope_RetrieveCustomerForOrder scope.

  2. Rename this activity by double-clicking the name underneath the icon. Do not double-click the activity icon itself.

  3. In the edit field, change the name to Scope_AuthorizeCreditCard.

  4. Click the Expand (+) icon to expand the Scope_AuthorizeCreditCard scope.

5.9.2 Task 2: Create the InvokeCheckCredit Invoke Activity

To create an invoke activity to call CreditCardAuthorizationService service:

  1. From the Component Palette, drag an Invoke activity into the Scope_AuthorizeCreditCard scope.

  2. Rename this activity by double-clicking name underneath the icon. Do not double-click the invoke icon itself.

  3. In the edit field, change the name to InvokeCheckCreditCard.

  4. Drag the mouse from the right side of InvokeCheckCreditCard to the CreditCardAuthorizationService partner link.

    The Edit Invoke dialog appears and is automatically filled in with the following information:

    Element Value
    Name InvokeCheckCreditCard
    Partner Link CreditCardAuthorizationService
    Operation AuthorizeCredit

  5. Click the Automatically Create Input Variable icon. It is the first icon to the right of the Input Variable field.

    The Create Variable dialog appears for the input variable. This variable provides input data to CreditCardAuthorizationService service.

  6. Enter and select the following values:

    Element Value
    Name lCreditCardInput
    Global Variable/Local Variable Local Variable.

  7. Click OK to close the Create Variable dialog.

    The Edit Invoke dialog populates with the variable in the Input Variable field.

  8. Click the Automatically Create Output Variable icon. It is the first icon to the right of the Output Variable field.

    The Create Variable dialog appears for the output variable. This variable returns status from CreditCardAuthorizationService service.

  9. Enter and select the following values:

    Element Value
    Name lCreditCardOutput
    Global Variable/Local Variable Local Variable

  10. Click OK to close the Create Variable dialog.

    The Edit Invoke dialog populates with the variable in the Output Variable field.

  11. In the Edit Invoke dialog, click OK to save the settings.

5.9.3 Task 3: Create the Assign_CreditCheckInput Activity

Next, you create an assign activity to take the credit card type, credit card number, and purchase amount and assign it to the input variable for the CreditAuthorizationService service.

  1. Create an assign activity to assign data to the input variables for the CreditCardAuthorizationService service:

    1. From the Component Palette, drag an Assign activity above the InvokeCheckCreditCard invoke activity.

    2. Rename this activity by double-clicking name underneath the icon. Do not double-click the assign icon itself.

    3. In the edit field, enter Assign_CreditCheckInput.

    4. Double-click the Assign_CreditCheckInput activity.

      The Assign dialog displays.

  2. Assign an input variable for the purchase amount to the CreditCardAuthorizationService service:

    1. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select ns4:OrderTotal.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_AuthorizeCreditCard > Variables > lCreditCardInput > Authorization > ns8:AuthInformation and select ns8:PurchaseAmount.

    3. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show the copy operation.

  3. Assign an input variable for the type of credit card to the CreditCardAuthorizationService service:

    1. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select ns4:CardTypeCode.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_AuthorizeCreditCard > Variables > lCreditCardInput > Authorization > ns8:AuthInformation and select ns8:CCType.

    3. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show the copy operation.

  4. Assign an input variable for the credit card account number to the CreditCardAuthorizationService service:

    1. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO > ns4:AccountNumber.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_AuthorizeCreditCard > Variables > lCreditCardInput > Authorization > ns8:AuthInformation and select ns8:CCNumber.

    3. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show three copy operations.

      Description of copyoperat3.gif follows
      Description of the illustration copyoperat3.gif

  5. In the Assign dialog, click OK.

  6. Select Save All from the File main menu to save your work.

5.9.4 Task 4: Create Switch Activity

To create the switch activity to check the results of the credit card validation:

  1. From the Component Palette, drag a Switch activity below the InvokeCheckCreditCard invoke activity.

  2. Rename this activity by double-clicking name underneath the icon. Do not double-click the assign icon itself.

  3. In the edit field, enter Switch_EvaluateCCResult.

  4. Click the Expand (+) icon to expand the switch.

  5. Specify the conditions for the <case> branch to handle cases where a customer's credit card is not valid. This information is stored in the lCreditCardOuput variable.

    1. Double-click the title bar of the <case> box to display the Switch Case dialog.

    2. In the Switch Case dialog, click the XPath Expression Builder icon above the Expression box to display the Expression Builder dialog.

      Description of switch.gif follows
      Description of the illustration switch.gif

    3. In the Expression Builder dialog, in the BPEL Variables box, select Scope - Scope_AuthorizeCreditCard > Variables > lCreditCardOuput > status and select ns8:status. The namespace number values (for example, ns1, ns2) can vary.

      The Content Preview box shows what to insert. For example:

      bpws:getVariableData('lCreditCardOutput','status','/ns8:status')
      
    4. Click Insert Into Expression.

      The Expression box updates with the three parameters.

    5. Append != 'APPROVED' to the expression in the Expression box so that the expression looks like this:

      bpws:getVariableData('lCreditCardOutput','status','/ns6:status') != 'APPROVED'
      
    6. Click OK to close the Expression Builder.

    7. In the Switch Case dialog, click OK.

  6. Remove the unneeded <otherwise> branch.

    1. Right-click the <otherwise> branch and select Delete from the menu.

    2. When prompted to remove the branch, click Yes.

  7. Create the Throw activity in the remaining <case> branch.

    For those orders not approved, this activity throws a fault called Throw_Fault_CC_Denied. The OrderProcessor process terminates after executing this throw activity.

    1. From the Component Palette, drag a Throw activity into the <case> branch.

    2. Double-click the new throw activity.

      The Throw activity dialog displays.

    3. Enter the following values:

      Element Value
      Name Throw_Fault_CC_Denied
      Namespace http://www.globalcompany.example.com/ns/OrderBookingService
      Local Part OrderProcessorFault
      Fault Variable Do not enter a value.

    4. Click OK.

  8. Click the Collapse (-) icon to minimize the switch.

  9. Select Save All from the File main menu to save your work.

5.10 Creating Catch Branches for the Scope_AuthorizeCreditCard

Add catch branches to the Scope_AuthorizeCreditCard scope for orders in which the credit card number is not provided or the credit type is not valid. Figure 5-4 shows the catches for the scope.

Figure 5-4 Catches in Scope_AuthorizeCreditCard

Description of Figure 5-4 follows
Description of "Figure 5-4 Catches in Scope_AuthorizeCreditCard"

To create the catches for this scope, perform the following tasks:

5.10.1 Task 1: Modify the OrderProcessor.wsdl File for the gOrderProcessorFaultVariable Variable

You create the gOrderProcessorFaultVariable variable as input for the branches in the next task. This variable uses the OrderProcessorFault element from the OrderProcessor.wsdl file, which you must create in the OrderProcessor.wsdl file.

To create this variable:

  1. From the Application Navigator, double-click OrderProcessor.wsdl.

    The WSDL Editor displays, which is a specialized schema-driven editor for editing WSDL documents.

  2. Click the Source tab and add the following definition to the wsdl:definitions section.

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    
  3. Click the Design tab.

  4. Create the OrderProcessorFault message:

    1. Click the Expand (+) icon in the Messages section.

      Description of processfault.gif follows
      Description of the illustration processfault.gif

    2. Click the Add icon to add a new message.

      The Create Message dialog displays.

    3. In the Message Name field, enter OrderProcessorFault, and then click OK.

    4. Select OrderProcessorFault in Messages.

    5. Select OrderProcessorFault and then select part in the right side WSDL component palette.

      Description of processfault2.gif follows
      Description of the illustration processfault2.gif

      The Create Part dialog displays.

    6. Enter and select following values:

      Element Value
      Part Name code
      Reference Type type
      Part Name xsd:string

    7. Click OK in the Create Part dialog.

    8. Select OrderProcessorFault and then select part in the right side of WSDL component palette.

      The Create Part dialog displays.

    9. Enter and select the following values:

      Element Value
      Part Name orderId
      Reference Type type
      Part Name xsd:string

    10. Click OK in the Create Part dialog.

    11. Select OrderProcessorFault and then select part in the right side WSDL component palette.

      The Create Part dialog displays.

    12. Enter and select the following values:

      Element Value
      Part Name summary
      Reference Type type
      Part Name xsd:string

    13. Click OK in the Create Part dialog.

      The Messages section displays the parts for the OrderProcessorFault message.

      Description of processfault3.gif follows
      Description of the illustration processfault3.gif

  5. Create the processFault operation for OrderProcessorCallback:

    1. In the Port Types section, select OrderProcessorCallback and then select operation in the right side WSDL component palette.

      The Create Operation dialog displays.

    2. Enter and select the following values:

      Element Value
      Operation Name processFault
      Operation Type Request Response
      Input client:OrderProcessorFault
      Output client:OrderProcessorResponseMessage

    3. Click OK in the Create Operation dialog.

    4. In the Port Types section, expand OrderProcessorCallback and processFault.

    5. Right-click the unneeded output in processFault and select Delete.

    6. Expand processFault > input > OrderProcessorFault > OrderProcessor to see the parts.

      Description of processfault4.gif follows
      Description of the illustration processfault4.gif

  6. Select Save All from the File main menu to save your work.

  7. Click X in the OrderProcessor.wsdl tab to close the WSDL Editor.

5.10.2 Task 2: Create the gOrderProcessorFaultVariable Variable

You now create the gOrderProcessorFaultVariable variable as input for the branches in the next task.

To create this variable:

  1. In the workspace for the OrderProcessor BPEL process, click the Variables icon.

    The Variables dialog displays.

  2. Click the Add icon to add a variable.

    Description of variableicon.gif follows
    Description of the illustration variableicon.gif

    The Create Variable dialog displays.

  3. In the Name field, enter gOrderProcessorFaultVariable.

  4. In the Type section, select Message Type and then select the Browse icon to the right of the Message Type field.

    The Type Chooser dialog appears with a list of available services.

  5. Expand Message Types > Project WSDL Files > OrderProcessor.wsdl > Message Types and select OrderProcessorFault, which you added to the WSDL file in Section 5.10.2, "Task 2: Create the gOrderProcessorFaultVariable Variable."

    Description of processfault5.gif follows
    Description of the illustration processfault5.gif

  6. Click OK to close the Type Chooser dialog.

  7. In the Create Variables dialog, click OK.

    The Variables dialog updates with the gOrderProcessorFault variable.

    Description of processfault6.gif follows
    Description of the illustration processfault6.gif

  8. Click OK in the Variables dialog.

5.10.3 Task 3: Add Catch Branches to the Scope_AuthorizeCreditCard

To add catches to the Scope_AuthorizeCreditCard scope:

  1. Click the Add Catch Branch icon for the scope, as shown in the following figure:

    Description of catchcredit.gif follows
    Description of the illustration catchcredit.gif

  2. Double-click the catch to display the Catch dialog.

  3. In the Fault QName section, click the Browse icon.

  4. In the Fault Chooser dialog, expand System Faults and select selectionFailure, and then click OK. This catch provides a built-in system fault. It is raised from the Assign_CreditCheckInput activity if any of the fields are blank, such as no account number.

  5. Click OK in the Catch dialog.

  6. Click the Expand (+) icon to expand the selectionFailure catch.

  7. In the selectionFailure catch, create an assign activity to assign expression 'CreditCardCheck - NO CreditCard' as input to global variable gOrderProcessorFaultVariable for orders without credit card numbers.

    1. From the Component Palette, drag an Assign activity into the branch.

    2. Rename this activity by double-clicking name underneath the icon. Do not double-click the assign icon itself.

    3. In the edit field, enter Assign_noCCNumber.

    4. Double-click Assign_noCCNumber.

      The Assign dialog displays.

    5. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    6. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      string('CreditCardCheck - NO CreditCard')
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderProcessorFaultVariable and select code. You created this variable in Section 5.10.2, "Task 2: Create the gOrderProcessorFaultVariable Variable."

    7. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show the copy operation.

    8. In the Assign dialog, click OK.

  8. In the selectionFailure catch, insert a throw activity after assign activity Assign_noCCNumber, so the Scope_AuthorizeCreditCard scope throws a fault:

    1. From the Component Palette, drag a Throw activity below Assign_noCCNumber.

    2. Double-click the new throw activity.

      The Throw activity dialog displays.

    3. Enter the following values:

      Element Value
      Name Throw_NoCreditCard
      Namespace http://www.globalcompany.example.com/ns/OrderProcessor
      Local Part OrderProcessorFault

    4. Click the Browse Fault Variables icon next to the Fault Variable field.

    5. In the Variable Chooser dialog, select the gOrderProcessFaultVariable and click OK.

    6. Back in the Throw dialog, click OK.

  9. Click the Collapse (-) icon to minimize the catch.

  10. Click the Add Catch Branch icon for the scope to create a second catch.

  11. Double-click the new catch to display the Catch dialog.

  12. Enter the following values:

    Element Value
    Namespace http://www.globalcompany.example.com/ns/CreditCardAuthorizationService
    Local Part InvalidCredit

  13. Click OK in the Catch dialog.

  14. Click the Expand (+) icon to expand the InvalidCredit catch.

  15. In the InvalidCredit catch, assign data to take the credit card type and assign it to global variable gOrderProcessorFaultVariable for orders without a valid credit card type.

    1. From the Component Palette, drag an Assign activity into the branch.

    2. Rename this activity by double-clicking name underneath the icon. Do not double-click the assign icon itself.

    3. In the edit field, enter Assign_InvalidCreditFault.

    4. Double-click Assign_InvalidCreditFault.

      The Assign dialog displays.

    5. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    6. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      1. Select the XPath Expression Builder icon.

        The Expression Builder displays.

      2. In the BPEL Variables section, expand Variables > gOrderInfoVariable > ns8:orderInfoVOSDO and select CardTypeCode.

      3. Click Insert Into Expression.

        The Expression box updates with the following expression:

        bpws:getVariableData('gOrderInfoVariable','/ns2:orderInfoVOSDO/ns8:CardTypeCode')
        
      4. Prepend the expression with the following Expression box, enter the following:

        concat(
        
      5. Append the expression with the following Expression box, enter the following:

        , ' is not a valid creditcard type')
        

        The expression should now looks like the following:

        concat(bpws:getVariableData('gOrderInfoVariable','/ns4:orderInfoVOSDO/ns4:CardTypeCode'), ' is not a valid creditcard type')
        
      6. Click OK to close the Expression Builder.

      To  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderProcessorFaultVariable and select summary.

    7. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show the copy operation.

  16. In the InvalidCredit catch, assign data expression 'CreditCardCheck - NOT VALID' to global variable gOrderProcessorFaultVariable.

    1. From the dropdown list in the Assign dialog, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      string('CreditCardCheck - NOT VALID')
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderProcessorFaultVariable and select code.

    3. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

      The Copy Operation tab in the Assign dialog updates to show the copy operation.

    4. In the Assign dialog, click OK.

  17. In the InvalidCredit catch, insert a throw activity after assign activity Assign_InvalidCreditFault, so the Scope_AuthorizeCreditCard scope throws a fault:

    1. From the Component Palette, drag a Throw activity below Assign_InvalidCreditFault.

    2. Double-click the new throw activity.

      The Throw activity dialog displays.

    3. Enter the following values:

      Element Value
      Name Throw_OrderProcessingFault
      Namespace http://www.globalcompany.example.com/ns/OrderProcessor
      Local Part OrderProcessorFault

    4. Click the Browse Fault Variables icon next to the Fault Variable field.

    5. In the Variable Chooser dialog, select the gOrderProcessFaultVariable and click OK.

    6. Click OK in the Throw dialog.

  18. Click the Collapse (-) icon to minimize the catch.

  19. Click the Collapse (-) icon to minimize the Scope_AuthorizeCreditCard scope.

  20. Select Save All from the File main menu to save your work.

5.11 Creating the RequiresApprovalRule Business Rule

You create a business rule activity to specify the RequiresApprovalRule business rule. This rule specifies that if the order total is $2,000 or more, then a manager's approval is required.

Another activity uses the output from the business rule to either automatically approve the order or use a human task to obtain manager approval.

When you add a business rule activity to a BPEL process, you can create input and output variables to provide input to the business rule activity, and to obtain results from the business rule activity.

To use business rules with Oracle JDeveloper, you perform the following:

If you want, you can associate a business rule service component created in the SOA Composite Editor with a BPEL process service component. You create this association with the business rule activity of the BPEL process. This activity creates a business rule partner link. This activity also enables you to create copy operation assignments between the fact data in your rule set and BPEL variables. When complete, a business rule activity is created that consists of assign and invoke activities to the business rule partner link.

To create the RequiresApprovalRule business rule, perform the following tasks:

5.11.1 Task 1: Create Scope_CheckApprovalLimit Scope

The Scope_CheckApprovalLimit scope invokes the RequiresApprovalRule business rule, as shown in Figure 5-5.

Figure 5-5 Scope_CheckApprovalLimit Scope

Description of Figure 5-5 follows
Description of "Figure 5-5 Scope_CheckApprovalLimit Scope"

To add the scope:

  1. From the Component Palette, drag a Scope activity below the Scope_AuthorizeCreditCard scope.

  2. Rename this activity by double-clicking the name underneath the icon. Do not double-click the activity icon itself.

  3. In the edit field, change the name to Scope_CheckApprovalLimit.

  4. Click the Expand (+) icon to expand the Scope_CheckApprovalLimit scope.

5.11.2 Task 2: Add the lOrderApproved Variable

In this task, you create local variable lOrderApproved variable, which provides input to a business rule variable.

To create this variable:

  1. In the workspace for the Scope_CheckApprovalLimit scope, click the Variables icon.

    The Variables dialog displays.

  2. Click the Add icon to add a variable.

    The Create Variable dialog displays.

  3. In the Name field, enter lOrderApproved.

  4. In the Type section, select Simple Type and then select the Browse XML Schema Types icon to the right of the field.

    The Type Chooser dialog appears with a list of available services.

  5. Select string under XML Schema Simple Types.

    Description of orderapprov.gif follows
    Description of the illustration orderapprov.gif

  6. Click OK in the Type Chooser dialog.

  7. Click OK in the Create Variable dialog.

    The Variables dialog updates with the lOrderApproved variable.

  8. Click OK in the Variables dialog.

5.11.3 Task 3: Create the Assign_DefaultNotRequiresApproval Assign Activity

In this task, you create an assign activity to take the order total and send it to the input variable for the business rule.

To assign an input variable for the purchase price to the business rule:

  1. From the Component Palette, drag an Assign activity into the Scope_CheckApprovalLimit scope.

  2. Rename this activity by double-clicking the name underneath the icon. Do not double-click the assign icon itself.

  3. In the edit field, enter Assign_DefaultNotRequiresApproval.

  4. Double-click the Assign_DefaultNotRequiresApproval activity.

    The Assign dialog displays.

  5. From the dropdown list, select Copy Operation:

    The Create Copy Operation dialog appears.

  6. Enter and select the following values:

    Element Value
    From  
    • Type
    Expression
    • Expression
    string('false')
    
    To  
    • Type
    Variable
    • Variable
    Expand Scope - Scope_CheckApprovalLimit > Variables and select lOrderApproved, which is the variable you created in Section 5.11.2, "Task 2: Add the lOrderApproved Variable."

  7. Click OK to close the Create Copy Operation dialog and return to the Assign dialog.

    The Copy Operation tab in the Assign dialog updates to show the copy operation.

  8. In the Assign dialog, click OK.

  9. Select Save All from the File main menu to save your work.

5.11.4 Task 4: Create the RequiresApprovalRule Business Rule

To create the business rule:

  1. Click the composite.xml tab to view the SOA Composite Editor.

  2. Drag a Business Rule service component into the SOA Composite Editor.

    The Create Business Rule dialog displays.

  3. In the Name field, enter RequiresApprovalRule to be the name of the Oracle Business Rules dictionary.

  4. Leave the default for the Package field.

  5. In the Inputs/Outputs section, from the Add menu, select Input to select the input for the business rule:

    The Type Chooser dialog displays.

  6. Import the complete schema located in the DEMO_DOWNLOAD_HOME directory:

    1. Click the Import Schema File icon.

      The Import Schema File dialog displays.

    2. Select File System and in the Location section, browse for OrderBookingRules.xsd in DEMO_DOWNLOAD_HOME/CompositeServices/OrderBookingComposite/xsd and click OK.

    3. In the Import Schema dialog, ensure the OrderBookingRules.xsd now displays in the URL field and the Copy to Project option is selected, and then click OK.

      The Localized Files dialog displays, prompting you to import the OrderBookingRules.xsd schema file.

    4. Deselect the Maintain original directory for imported files option and click OK to import the file.

      The Type Chooser dialog displays.

  7. Select the input for the business rule:

    1. In the Type Chooser dialog, expand OrderBookingRules.xsd and select approve.

    2. Click OK to return to the Create Business Rules dialog.

  8. In the Inputs/Outputs section, select the output for the business rule:

    1. From the Add menu, select Output.

      The Type Chooser dialog displays.

    2. Expand OrderBookingRules.xsd and select approve.

    3. Click OK to return to the Create Business Rules dialog.

  9. Click OK to create the business rule.

    The RequiresApprovalRule business rule displays in the composite.

  10. Select Save All from the File main menu to save your work.

  11. Double-click RequiresApprovalRule in the SOA Composite Editor.

    Oracle JDeveloper displays the Rules Designer, with the dictionary in the RequiresApprovalRule.rules tab.

    Description of requirespp5.gif follows
    Description of the illustration requirespp5.gif

    For an overview of the Rules Designer, see Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

    As part of the Business Rule designer, a new rule dictionary is created with the following pre-loaded data:

    • XML fact type model based on the input and output metadata information of the business rule activity.

    • A new ruleset that must be completed by adding rules to it.

    • A new service with the input and output contract of the business rule activity. The service is being invoked from the activity at run time.

    • A new business rule service component for the rule dictionary. You wire it to the BPEL process in Section 5.11.5, "Task 5: Reference the RequiresApprovalRule Dictionary in the BPEL Designer."

    You modify this rule in a later task. Therefore, do not close the tab.

5.11.5 Task 5: Reference the RequiresApprovalRule Dictionary in the BPEL Designer

To reference the RequiresApprovalRule in the Scope_CheckApprovalLimit scope:

  1. Click the OrderProcessor.bpel tab.

  2. From the Component Palette, drag a Business Rule activity below the Assign_DefaultNotRequiresApproval activity in the Scope_CheckApprovalLimit scope.

    The Business Rule dialog displays.

  3. In the Name field, enter BusinessRule_ApprovalRequired.

  4. From the Dictionary list, select RequiresApprovalRule, which is the rule you created in Section 5.11.4, "Task 4: Create the RequiresApprovalRule Business Rule."

  5. Leave the default settings for the Service and Operation fields.

  6. Create input to the business rule, so that the gOrderInfoVariable and lOrderApproved variables assign data to input variable com_example_globalcompany_ns_orderbookingservice_rules_Approve_i for the business rule.

    1. In the Assign Input Facts tab, click the Create icon.

      The Decision Fact Map dialog displays.

    2. Enter and select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select ns4:OrderTotal.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Business Rules Facts
      • Variable
      Expand com_example_globalcompany_ns_orderbookingservice_rules_Approve_i > ns10:approve and select ns10:price.

    3. Click OK.

      The copy operation displays in the Assign Input Facts tab of the Business Rule dialog.

    4. In the Assign Input Facts tab, click the Create icon again to create a second assignment.

      The Decision Fact Map dialog displays.

    5. Enter and select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_CheckApprovalLimit > Variables and select lOrderApproved.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Business Rule Facts
      • Variable
      Expand com_example_globalcompany_ns_orderbookingservice_rules_Approve_i > ns10:approve and select ns10:approvalRequired.

    6. Click OK.

      The two copy operations display in the Assign Input Facts tab of the Business Rule dialog.

  7. Create output from the business rule, so that the variable com_example_globalcompany_ns_orderbookingservice_rules_Approve_o for the business rule sends data to the lOrderApproved variable for the scope:

    1. Click the Assign Output Facts tab.

    2. In the Assign Output Facts tab, click the Create icon.

      The Decision Fact Map dialog displays.

    3. Enter and select the following values:

      Element Value
      From  
      • Type
      Business Rule Facts
      • Variable
      Expand com_example_globalcompany_ns_orderbookingservice_rules_Approve_o > ns10:approve and select ns10:approvalRequired.

      Note: The namespace number values (for example, ns1, ns2) can vary.

      To  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_CheckApprovalLimit > Variables and select lOrderApproved.

    4. Click OK.

      The copy operation displays in the Assign Input Facts tab of the Business Rule dialog.

  8. Click OK in the Business Rules dialog.

  9. Select Save All from the File main menu to save your work.

5.11.6 Task 6: Define a Variable in Rules Designer

You define variables in the data model. When you make changes later, you must edit the value of the variable. You create a variable named MAX_PRICE to define the dollar amount where orders above this amount would need manual approval from a manager and orders under this amount are approved automatically. You set the MAX_PRICE variable to $2000.

To create the MAX_PRICE variable:

  1. In the Rules Designer, select the Globals tab.

  2. Click the Create icon to add a new variable entry.

    The Edit Variable dialog displays.

  3. In the Name field, enter MAX_PRICE.

  4. In the Description field, enter the following string:

    Limit for Automatic Approval
    
  5. From Type dropdown list, select int.

  6. Do not select any value for Bucketset.

  7. Click the icon next to the Value field.

    The Expression Builder dialog displays.

  8. In the Expression area, enter 2000, and then click OK to close the Expression Builder.

  9. In the Edit Variable dialog, click OK.

5.11.7 Task 7: Add a New Rule for the Ruleset in Rules Designer

When you create the rule dictionary, an empty ruleset named Ruleset_1 was created without any rules. In this task, you add the CheckOrderTotalAgainstLimit rule. This rule specifies that if the order is greater than or equal to $2,000, then the order requires manual approval.

To create the rule:

  1. In Rules Designer, select Ruleset_1 from the left menu.

  2. From the Create dropdown list, select Create Rule.

    A new rule displays:

    Description of rulesdesign3.gif follows
    Description of the illustration rulesdesign3.gif

  3. Click <insert test> to display the statement template.

  4. In the IF section, click the left-hand operand and select approve.price.

    Description of rulesdesign4.gif follows
    Description of the illustration rulesdesign4.gif

  5. Click the operator and select >=.

  6. Click the right-hand operand and select MAX_PRICE.

  7. In the THEN section, click <insert action> and select modify.

  8. Click <target> and select approve.

  9. Click <add property>.

    The Properties dialog displays.

    Description of rulesdesign5.gif follows
    Description of the illustration rulesdesign5.gif

  10. In the approvalRequired row, select true from the Value dropdown menu and click the Constant check box.

  11. Click Close.

    The business rule updates and is complete.

    Description of rulesdesign6.gif follows
    Description of the illustration rulesdesign6.gif

  12. Select Save All from the File main menu to save your work.

  13. Click X in the RequiresApprovalRule.rules tab to close the Rules Designer.

5.11.8 Task 8: Redeploy the OrderBookingComposite Composite

To redeploy the OrderBookingComposite composite:

  1. In the Application Navigator, right-click OrderBookingComposite and select Deploy > OrderBookingComposite > to MyAppServerConnection.

    The SOA Deployment Configuration Dialog displays.

  2. Select Overwrite any existing composite with the same revision ID to overwrite the composite you deployed in Section 5.7.4, "Task 4: Deploy the OrderBookingComposite Composite."

  3. When prompted with the Authorization Request dialog, enter weblogic in the Username field and the password in the Password field.

    In SOA - Log, a series of validations display, followed by:

    BUILD SUCCESSFUL
    Total time: nn seconds
    

5.11.9 Task 9: Initiate a Test Instance for the OrderBookingComposite Composite

Initiate a test instance of the OrderBookingComposite composite, as you did in Section 5.7.6, "Task 6: Initiate a Test Instance for the OrderBookingComposite Composite." This time, in the Flow Trace window, notice how the order progresses through the Scope_CheckApprovalLimit scope.

5.12 Adding the Switch_ApprovalRequired Switch to the Scope_CheckApprovalLimit Scope

For an order that requires manual approval because the order total is $2,000 or more, the SwitchApprovalRequired switch in the ScopeCheckApprovalLimit scope consists of a <case> branch that passes control to the ApprovalHumanTask human task activity, which enables a manager named jstein to approve or reject the orders. For orders that do not require manual approval, this switch does not apply to them.

Figure 5-6 shows the SwitchApprovalRequired switch contains a human task activity and another switch activity to handle the manager's response.

Figure 5-6 Switch_ApprovalRequired Switch with Human Task and Switch

Description of Figure 5-6 follows
Description of "Figure 5-6 Switch_ApprovalRequired Switch with Human Task and Switch"

To create the SwitchApprovalRequired switch, perform the following tasks:

5.12.1 Task 1: Create the Switch_ApprovalRequired Switch

To create the Switch_ApprovalRequired switch:

  1. Click the OrderProcessor.bpel tab.

  2. From the Component Palette, drag a Switch activity from the Component Palette section to below the BusinessRule_ApprovalRequired activity.

  3. Rename this activity by double-clicking the name underneath the icon. Do not double-click the activity icon itself.

  4. In the edit field, change the name to Switch_ApprovalRequired.

  5. Click the Expand (+) icon to expand the Switch_ApprovalRequired scope.

  6. Remove the unneeded <otherwise> branch.

    1. Right-click the <otherwise> branch and select Delete from the menu.

    2. When prompted to remove the branch, click Yes.

      The switch looks similar to the one in the following figure:

      Description of requirespp1.gif follows
      Description of the illustration requirespp1.gif

  7. Select Save All from the File main menu to save your work.

5.12.2 Task 2: Set the Condition for the <case> Branch

To create the <case> branch:

  1. Double-click the title bar of the <case> box to display the Switch Case dialog.

    The Switch Case dialog displays.

  2. In the Name box, enter:

    approval required = true
    
  3. Click the XPath Expression Builder icon above the Expression box to display the Expression Builder dialog.

  4. In the BPEL Variables box, expand Scope - Scope_CheckApprovalLimit > Variables and select lOrderApproved.

    lOrderApproved is the variable you defined in Section 5.11.2, "Task 2: Add the lOrderApproved Variable."

    The Content Preview box should show the following:

    bpws:getVariableData('lOrderApproved')
    
  5. Click Insert Into Expression. The Expression box displays the function with the one parameter.

  6. Append = 'true' to the expression, starting with a space, in the Expression box so that the expression looks like this:

    bpws:getVariableData('lOrderApproved') = 'true'
    
  7. Click OK in the Expression Builder dialog. The Switch Case dialog now contains the expression.

  8. Click OK in the Switch Case dialog to close it.

  9. Select Save All from the File main menu to save your work.

    You modify the <case> branch with two activities, a human task activity and a switch activity). To create these activities, you must create a sequence activity to be the container for these two activities.

5.12.3 Task 3: Create a Human Task in the <case> Branch to Approve an Order

To create a human task in the <case> branch:

  1. Drag a Human Task activity into the <case> box.

    The Create a Human Task dialog appears.

  2. From the Task Definition list, click the Create icon next to the Task Definition field.

    The Create Human Task dialog displays.

  3. Enter and select the following values:

    Element Value
    Name ApprovalHumanTask
    Priority Leave the priority set to 3 (Normal).
    Namespace http://www.globalcompany.com/ns/OrderBooking/ApprovalHumanTask
    Title Do not enter a value for the time being.

  4. In the Parameters section, select the Add Task Parameter icon.

    The Add Task Parameter dialog displays.

  5. Click the icon next to the Source field to launch the Task Parameters page for selecting a parameter source.

  6. Expand Variables > gOrderInfoVariable > ns8:orderInfoVOSDO and select the OrderId key.

  7. Click OK to close the Task Parameters dialog.

  8. Back in the Add Task Parameter dialog, in the Parameter Name field, modify the field to orderId.

  9. Click OK to close the Add Task Parameter dialog and return to the Create Human Task dialog.

    Description of humancreat.gif follows
    Description of the illustration humancreat.gif

  10. In the Create Human Task dialog, click OK.

    The Human Task Editor appears.

    Description of humancreat2.gif follows
    Description of the illustration humancreat2.gif

    For an overview of the Human Task Editor, see Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

  11. Define a title for the task

    1. In the Title field, enter:

      Approval Required for Order Id:
      
    2. Click the icon to the right of the Title field to select the order ID.

      The Expression Builder dialog displays.

    3. From the Schema section, expand task:task > task:payload and select task:orderId.

      Description of humancreat3.gif follows
      Description of the illustration humancreat3.gif

    4. Click Insert Into Expression.

      The Expression box updates with the following expression:

      /task:task/task:payload/task:orderId
      
    5. Click OK to close the Expression Builder.

      The ApprovalHumanTask.task pages updates with the following for the title:

      Approval Required for Order Id:<%/task:task/task:payload/task:orderId%>>
      
  12. Specify an approver for the human task:

    1. In the Assignment and Routing Policy section, double-click <no participants>.

      Description of humancreat4.gif follows
      Description of the illustration humancreat4.gif

      The Add Participant Type dialog displays.

    2. In the Label field, enter Approver.

    3. From the dropdown menu in the Participant Names table, select Add User.

      A new row displays in the Participant Names table.

    4. Click the Browse icon to the far right of the row.

      Description of humancreat6.gif follows
      Description of the illustration humancreat6.gif

      The Identity Lookup dialog appears.

    5. From the Application Server list, select MyAppServerConnection.

    6. Click the Lookup icon. It is located to the right of the User Name field.

      The search results display in the Search User section.

    7. Select jstein and then click Select.

      jstein is added to the Selected User section.

    8. Click OK to close the Identity Lookup dialog.

      jstein displays in the Participants Names table in the Edit Participant Type dialog.

    9. Click OK in the Add Participant Type dialog.

      Approver displays in the Assignment and Routing Policy section of the ApprovalHumanTask.task window.

      Description of approveorder.gif follows
      Description of the illustration approveorder.gif

  13. Select Save All from the File main menu to save your work.

  14. Click X in the ApprovalHumanTask.task tab to close the human task.

  15. Click the composite.xml tab to see the human task.

    ApprovalHumanTask displays in the SOA Composite Editor.

    Description of compositehuman.gif follows
    Description of the illustration compositehuman.gif

5.12.4 Task 4: Modify TaskSwitch Activity in <case> Branch to Handle Manager's Response

Oracle JDeveloper created a switch called taskSwitch for you automatically after the human task activity in the OrderProcessor BPEL process, as shown in Figure 5-7.

Figure 5-7 taskSwitch Activity in the <case> Branch

Description of Figure 5-7 follows
Description of "Figure 5-7 taskSwitch Activity in the <case> Branch"

This switch enables you to define the actions to take depending on whether the manager approved or rejected the order, or if the order has expired.

The switch handles these cases:

  • The manager rejected the order.

  • The manager approved the order.

  • The order has expired.

To modify the switch for these actions:

  1. Click the Expand (+) icon to expand the taskSwitch.

  2. In the <case Task outcome is REJECT> branch, remove the CopyPayloadFromTask activity and replace it with a throw activity.

    For those orders not approved, this activity throws a fault called Throw_OrderProcessorFault. The OrderProcessor process terminates after executing the throw activity.

    1. Right-click the CopyPayloadFromTask activity and select Delete from the menu.

    2. When prompted to remove the branch, click Yes.

    3. From the Component Palette, drag a Throw activity into the <case Task outcome is REJECT> branch.

    4. Double-click the new throw activity.

      The Throw activity dialog displays.

    5. Enter and select the following values:

      Element Value
      Name Throw_OrderProcessorFault
      Namespace http://www.globalcompany.example.com/ns/OrderBookingService
      Local Part OrderProcessorFault
      Fault Variable
      1. Click the Browse icon.
      2. In the Variable Chooser dialog, select gOrderProcessorFaultVariable.

      3. Click OK.


    6. Click OK.

  3. In the <case Task outcome is APPROVE> branch, remove the CopyPayloadFromTask activity and replace it with an empty assign activity. the empty assign passed the output from the business to the next scope in the process.

    1. Right-click the CopyPayloadFromTask activity and select Delete from the menu.

    2. When prompted to remove the branch, click Yes.

    3. From the Component Palette, drag an Empty activity into the <case Task outcome is APPROVE> branch.

    4. Rename this activity by double-clicking the name underneath the icon.

    5. In the edit field, remove the name.

  4. In the Assign dialog, click OK.

  5. In the <otherwise> branch, remove the CopyPayloadFromTask activity and replace it with a throw activity.

    For those orders not approved, this activity throw a fault called ThrowRejected. The OrderProcessor process terminates after executing the throw activity.

    1. Right-click the CopyPayloadFromTask activity and select Delete from the menu.

    2. When prompted to remove the branch, click Yes.

    3. From the Component Palette, drag a Throw activity into the <otherwise Task> branch.

    4. Double-click the new throw activity.

      The Throw activity dialog displays.

    5. Enter and select the following values:

      Element Value
      Name Throw_OrderProcessingFault
      Namespace http://www.globalcompany.example.com/ns/OrderBookingService
      Local Part OrderProcessorFault
      Fault Variable
      1. Click the Browse icon.
      2. In the Variable Chooser dialog, select gOrderProcessorFaultVariable.

      3. Click OK.


    6. Click OK.

  6. Click the Collapse (-) icon to minimize taskSwitch switch.

  7. Click the Collapse (-) icon to minimize the Scope_CheckApprovalLimit scope.

  8. Select Save All from the File main menu to save your work.

5.12.5 Task 5: Redeploy the OrderBookingComposite Composite

To redeploy the OrderBookingComposite composite:

  1. In the Application Navigator, right-click OrderBookingComposite and select Deploy > OrderBookingComposite > to MyAppServerConnection.

    The SOA Deployment Configuration Dialog displays.

  2. Select Overwrite any existing composite with the same revision ID to overwrite the composite you previously deployed.

  3. When prompted with the Authorization Request dialog, enter weblogic in the Username field and the password in the Password field.

    In SOA - Log, a series of validations display, followed by:

    BUILD SUCCESSFUL
    Total time: nn seconds
    

5.12.6 Task 6: Initiate a Test Instance for the OrderBookingComposite Composite

Initiate a test instance of the OrderBookingComposite composite, as you have done previously. See Section 5.7.6, "Task 6: Initiate a Test Instance for the OrderBookingComposite Composite" for further information on creating a test instance. For this test instance, make the following adjustments:

  • In the Inputs Arguments section, in the orderID field, enter an ID over 1000 to submit an order for over $2000.

  • In the Flow trace window, scroll toward the bottom of the Scope_CheckApprovalLimit scope to see the ApprovalHumanTask human task was initiated after the business rule.

Proceed with Chapter 6, "Creating the Second Half of the OrderProcessor BPEL Process," to complete the creation of the OrderProcessor BPEL process. After the process is complete, you can create a form for the manager to approve orders in Chapter 9, "Creating the Task Display Form for the ApprovalHumanTask Human Task."