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

6 Creating the Second Half of the OrderProcessor BPEL Process

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

This chapter contains the following sections:

6.1 Overview of Tasks for Creating the Second Half of OrderProcessor

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

Table 6-1 Tasks for Creating the Second Half of the OrderProcessor BPEL Process for OrderBookingComposite

Task Description See

Create the Scope_RetrieveQuotes Flow

Create the Scope_RetrieveQuotes flow to send the order information to two suppliers, an internal warehouse and an external partner warehouse, and have the warehouses return their bids for the orders.

Section 6.2

Create the Scope_SelectPreferredSupplier Scope

Create the Scope_SelectPreferredSupplier scope to use the EvaluatePreferredSupplierRule business rule to select the warehouse with the lowest order total.

Section 6.3

Create the Services and Routing Required for the Scope_FulfillOrder Scope

Create adapters for USPS and a JMS queue. Also, create a mediator to send orders for fulfillment to these adapters.

Section 6.4

Create the Scope_FulfillOrder Scope

Create the Scope_FulfillOrder scope to submit orders to the FulfillOrder mediator, which sends the order to both the USPS and JMS adapters.

Section 6.5

Create the Scope_UpdateStatusToComplete Scope for Completed Orders

Create the Scope_UpdateStatusToComplete scope to assign a status of complete to the order entity variable, which updates the order in the database. If you did not use an entity variable, you would have to create a database adapter.

Section 6.6

Create the Scope_NotifyCustomerofCompletion Scope

Create the Scope_NotifyCustomerofCompletion scope to use the Oracle User Messaging Service to send an email to the customer when the order is fulfilled.

Section 6.7

Add a Catch Branch for Incomplete Orders for the Entire Process

Add a catch branch to the process as a whole so that you can update the order status to be canceled if an error occurs anywhere in the process.

Section 6.8


6.2 Creating the Scope_RetrieveQuotes Flow

The Scope_RetrieveQuotes flow sends the order information to two suppliers, an internal warehouse and an external partner warehouse, and the warehouses return their bids for the orders. The Scope_SelectPreferredSupplier scope then chooses the warehouse based on the lowest bid.

Figure 6-1 shows the activities in the Scope_RetrieveQuotes scope. The scope uses a flow activity to send the order information to the two warehouses in parallel.

Figure 6-1 Activities for the Scope_RetrieveQuotes Scope

Description of Figure 6-1 follows
Description of "Figure 6-1 Activities for the Scope_RetrieveQuotes Scope "

Figure 6-2 shows the OrderProcessor BPEL process invokes the InternalWarehouse service and receives a quote from it. This service references a WSDL file from a BPEL process also named InternalWarehouseService, which resides within the OrderBookingComposite composite. Figure 6-3 shows how it appears in the SOA Composite Editor. This supplier statically returns a value of $1,000 for all orders regardless of their order total.

Figure 6-2 Activities for Receiving a Bid from an Internal Warehouse

Description of Figure 6-2 follows
Description of "Figure 6-2 Activities for Receiving a Bid from an Internal Warehouse "

Figure 6-3 InternalWarehouseService in OrderBookingComposite

Description of Figure 6-3 follows
Description of "Figure 6-3 InternalWarehouseService in OrderBookingComposite"

Figure 6-4 show the OrderProcessor BPEL process invokes the PartnerSupplierMediator mediator and receives a quote from it. This mediator initiates the ExternalPartnerSupplier BPEL process in the PartnerSupplierComposite, which you created in Chapter 1, "Introduction to the SOA Sample Application." Figure 6-5 shows how the mediator and service appear in the SOA Composite Editor.

Figure 6-4 Activities for Receiving a Bid from a Partner Warehouse

Description of Figure 6-4 follows
Description of "Figure 6-4 Activities for Receiving a Bid from a Partner Warehouse"

Figure 6-5 PartnerSupplierService in OrderBookingComposite

Description of Figure 6-5 follows
Description of "Figure 6-5 PartnerSupplierService in OrderBookingComposite"

To create the Scope_RetrieveQuotes scope and related services, perform the following tasks:

6.2.1 Task 1: Add the Scope_RetrieveQuotes Scope

To add the Scope_RetrieveQuotes scope:

  1. From the Component Palette, drag a Scope activity below the Scope_CheckApprovalLimit 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_RetrieveQuotes.

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

  5. Drag and drop a Flow activity into the scope.

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

  7. In the edit field, enter RetrieveQuotesFromSuppliers.

  8. Click the Expand (+) icon to expand the Scope_RetrieveQuotes scope.

    The flow should now contains two empty sequences.

    Description of flowempty.gif follows
    Description of the illustration flowempty.gif

6.2.2 Task 2: Create the InternalWarehouseService BPEL Process

To create the InternalWarehouseService BPEL process:

  1. Click the composite.xml tab.

  2. Select SOA from the Component Palette.

  3. Drag a BPEL Process from the Service Components list into the canvas workspace.

    The Create BPEL Process dialog appears.

  4. Enter and select the following values:

    Element Value
    Name InternalWarehouseService
    Namespace http://www.globalcompany.example.com/ns/InternalWarehouse
    Template Asynchronous BPEL Process
    Expose as a SOAP service Deselect this check box.

  5. In the Input field, import the complete schema located in the DEMO_DOWNLOAD_HOME directory.

    1. In the Input field, click the Browse Input Elements icon.

      The Type Chooser dialog displays.

    2. Expand Project Schema Files > InternalWarehouse.xsd and select WarehouseRequest and then click OK.

    3. Click OK.

  6. In the Output field, import the complete schema located in the DEMO_DOWNLOAD_HOME directory.

    1. In the Input field, click the Browse Input Elements icon.

      The Type Chooser dialog displays.

    2. Expand Project Schema Files > InternalWarehouse.xsd and select WarehouseResponse and then click OK.

  7. Click OK.

    The BPEL process displays in the SOA Composite Editor.

  8. Double-click InternalWarehouseService BPEL process to display the BPEL Designer.

    Description of warehouse.gif follows
    Description of the illustration warehouse.gif

6.2.3 Task 3: Modify the InternalWarehouseService Process

Next, you create an assign activity to copy input data to the InternalWarehouseService service:

  1. Create the assign activity:

    1. From the Component Palette, drag an Assign activity to below the receiveInput receive 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 Assign_Defaults.

    4. Double-click the assign activity.

      The Assign dialog displays.

  2. Copy string 'InternalWarehouse' to the output variable for the InternalWarehouseService service:

    1. From the dropdown list, select Copy Operation:

      The Create Copy Operation dialog appears.

    2. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      string('InternalWarehouse')
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > outputVariable > payload > client:WarehouseResponse and select client:warehouse.

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

  3. Assign the current date to the output variable for the InternalWarehouseService service:

    1. From the dropdown list, select Copy Operation:

      The Create Copy Operation dialog appears.

    2. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      xp20:current-date()
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > outputVariable > payload > ns3:WarehouseResponse and select ns3:deliveryDate. The namespace number values (for example, ns1, ns2) can vary.

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

  4. Assign 1000 to the output variable for the InternalWarehouseService service. This value ensures this warehouse statically returns a value of $1,000 for all orders.

    1. From the dropdown list, select Copy Operation:

      The Create Copy Operation dialog appears.

    2. Enter and select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      1000
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > outputVariable > payload > ns3:WarehouseResponse and select ns3:orderTotal. The namespace number values (for example, ns1, ns2) can vary.

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

  5. In the Assign dialog, click OK.

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

  7. Click X in the InternalWarehouseService.bpel tab to close the process.

6.2.4 Task 4: Wire OrderProcessor to the InternalWarehouseService Process

To wire the OrderProcessor BPEL process to the InternalWarehouseService service:

  1. Drag a wire from OrderProcessor to the InternalWarehouseService reference handle.

    Description of wire4.gif follows
    Description of the illustration wire4.gif

    You should see a wire going from the OrderProcessor BPEL process to the InternalWarehouseService process in the SOA Composite Editor.

    Description of composite12.gif follows
    Description of the illustration composite12.gif

  2. Click the OrderProcessor.bpel tab to see the InternalWarehouseService in the Partner Links lane of the BPEL Designer.

    Description of internalwarebp.gif follows
    Description of the illustration internalwarebp.gif

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

6.2.5 Task 5: Create the PartnerSupplierService Service

The PartnerSupplierMediator mediator obtains a quote from a partner warehouse service named PartnerSupplierService, which calls the PartnerSupplierComposite you created in Chapter 3. Before you create the PartnerSupplierMediator mediator, you must create the PartnerSupplierService service. This service references the WSDL created when you created the ExternalPartnerSupplier BPEL process in Chapter 3.

To create a Web service for the PartnerSupplierService service:

  1. If the PartnerSupplierComposite composite was not deployed when you created the composite, deploy it now:

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

      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
      
  2. In the composite.xml tab, from the Component Palette, drag a Web Service from the Service Adapters list into the right swim lane of the SOA Composite Editor.

    The Web Service window appears.

  3. In the Name field, enter PartnerSupplierService.

  4. From the Type list, select Reference.

  5. Click the Find existing WSDLs icon next to the WSDL URL field.

    The SOA Resource Lookup dialog displays.

  6. Select Resource Palette.

  7. Expand Application Server > MyApplicationServerConnection > SOA > PartnerSupplierComposite and select externalpartnersupplier_client_ep.

  8. Click OK in the SOA Resource Lookup dialog.

  9. In the Web Service dialog, from the Port Type list, select ExternalPartnerSupplier and from the Callback Port Type list, select ExternalPartnerSupplierCallback.

  10. Click OK in the Web Service dialog.

    The PartnerSupplierService service displays in the SOA Composite Editor.

    Description of partnersupplierser.gif follows
    Description of the illustration partnersupplierser.gif

6.2.6 Task 6: Create a PartnerSupplier Mediator Service for the PartnerSupplierService Service

The PartnerSupplierMediator mediator service obtains a quote from the PartnerSupplierService service:

To create the mediator:

  1. From the Component Palette, drag a Mediator service into the middle lane of the SOA Composite Editor.

    The Create Mediator window appears.

  2. In the Name field, enter PartnerSupplierMediator.

  3. From the Template list, select Interface Definition from WSDL

  4. Deselect the Create Composite Service with SOAP Bindings.

  5. From the WSDL URL field, generate a WSDL file:

    1. Click the Generate WSDL from schema(s) icon.

      The Create WSDL dialog displays.

    2. In the URL field, click the browse for schema file icon.

      The Type Chooser dialog displays.

    3. Expand Project Schema Files > OrderInfoVOSDO.xsd and select orderInfoVOSDO.

    4. Click OK to close the Type Chooser and return to the Create WSDL dialog.

    5. In the Namespace field, enter http://www.globalcompany.example.com/ns/PartnerSupplierMediator.

      Description of partnersuppliermed.gif follows
      Description of the illustration partnersuppliermed.gif

    6. Click the Callback tab.

    7. In the URL field, click the browse for schema file icon.

      The Type Chooser dialog displays.

    8. Expand Project Schema Files > InternalWarehouseService.xsd and select WarehouseResponse.

    9. Click OK in the Type Chooser dialog.

    10. Click OK in the Create WSDL dialog and return to the Create Mediator dialog.

  6. In the Create Mediator dialog, deselect the Create Composite Services with SOAP Bindings option, and then click OK to create the mediator with the specified settings.

    Description of partnersuppliermed2.gif follows
    Description of the illustration partnersuppliermed2.gif

    The PartnerSupplierMediator mediator displays in the SOA Composite Editor.

    Description of partnersuppliermed3.gif follows
    Description of the illustration partnersuppliermed3.gif

6.2.7 Task 7: Create Routing Rules Between the PartnerSupplierMediator Mediator to the ExternalPartnerSupplier Service

To route order information from a mediator to a service, you set up routing rules.

To create a routing rule from the PartnerSupplierMediator mediator to the PartnerSupplier service:

  1. Drag a wire from PartnerSupplierMediator to the PartnerSupplierService reference handle.

    Description of wire2.gif follows
    Description of the illustration wire2.gif

  2. Double-click PartnerSupplierMediator to view the Mediator Editor.

    Description of partnersupp.gif follows
    Description of the illustration partnersupp.gif

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

  3. Modify the payload transformation so that the PartnerSupplierService service receives the proper information from the mediator.-

    1. Click the transformation icon next to the Transform Using field.

      Description of transformation.gif follows
      Description of the illustration transformation.gif

      The Request Transformation Map dialog displays.

    2. Select Create New Mapper File and leave the default file entry as orderItemsInfoVOSDO_To_WarehouseProcessRequest.xsl, and then click OK.

      The Data Mapper displays.

      Description of mapper1.gif follows
      Description of the illustration mapper1.gif

    3. On the Source:PartnerSupplierMediator.wsdl (left) side, click and drag OrderTotal to orderTotal on the XSLT File:ExternalPartnerSupplier.wsdl (right) side.

    4. On the Source:PartnerSupplierMediator.wsdl (left) side, expand OrderItemsInfoVO.

    5. On the Source:PartnerSupplierMediator.wsdl (left) side, click and drag OrderItemsInfoVO to orderItems on the XSLT File: ExternalPartnerSupplier.wsdl (right) side.

      The Auto Map Preferences dialog prompts to perform automatic mapping of the node.

    6. Leave the default settings and click OK.

    7. In the Data Mapper expand for-each > orderItems to see the mappings from OrderItemsInfoVO to orderItems.

      Description of mapper2.gif follows
      Description of the illustration mapper2.gif

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

    9. Click X in the IorderInfoVOSDO_To_WarehouseProcessRequest.xsl tab to close the Data Mapper.

    10. With the PartnerSupplier.mplan tab back in focus, in the Routing Rules section, you should see file orderInfoVO_To_WarehouseProcessRequest.xsl in the Transform Using field.

      Description of partnersupp3.gif follows
      Description of the illustration partnersupp3.gif

  4. Modify the callback transformation so that the PartnerSupplierMediator mediator receives the proper information from the PartnerSupplierService service:

    1. Click the transformation icon next to the Transform Using field.

      The Request Transformation Map dialog displays.

    2. Select Create New Mapper File and leave the default file entry as WarehouseProcessResponse_To_WarehouseProcessResponse.xsl, and then click OK.

      The Data Mapper displays.

    3. On the Source:ExternalPartnerSupplier.wsdl (left) side, click and drag OrderTotal to orderTotal on the XSLT File:PartnerSupplierMediator.wsdl (right) side.

    4. On the Source:ExternalPartnerSupplier.wsdl (left) side, click and drag client:deliveryDate to deliveryDate on the XSLT File:PartnerSupplierMediator.wsdl (right) side.

      The mappings in the Data Mapper should look like the following:

      Description of mapper3.gif follows
      Description of the illustration mapper3.gif

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

    6. Click X in the WarehouseProcessResponse_To_WarehouseProcessResponse.xsl tab to close the Data Mapper.

    7. With the PartnerSupplierMediator.mplan tab back in focus, in the Routing Rules section, you should see file WarehouseProcessResponse_To_WarehouseResponse.xsl in the Transform Using field.

      Description of partnersupp4.gif follows
      Description of the illustration partnersupp4.gif

  5. Click X in the PartnerSupplier.mplan tab to close Mediator Editor.

6.2.8 Task 8: Wire OrderProcessor to the PartnerSupplierMediator Mediator

  1. Click the composite.xml tab.

  2. Drag a wire from OrderProcessor to the PartnerSupplierMediator reference handle.

    Description of wire5.gif follows
    Description of the illustration wire5.gif

  3. Click the OrderProcessor.bpel tab to see PartnerSupplierMediator added to the Partner Links lane as a service.

    Description of partnersuppbp.gif follows
    Description of the illustration partnersuppbp.gif

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

6.2.9 Task 9: Add the gWarehouseQuotes Variable

In this task, you create the gWarehouseQuotes variable, which provides output from the Scope_RetrieveQuotes scope and input to the Scope_SelectPreferredSupplier scope. This variable provides the response for the warehouses, including the warehouse name, delivery date, and order total.

To create this variable:

  1. In the canvas workspace for the OrderProcessor BPEL process, 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 gWarehouseQuotes.

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

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

  5. Expand Project WSDL Files > InternalWarehouseService.wsdl > Inline Schemas > Schema and select WarehouseList.

    Description of warehouselst.gif follows
    Description of the illustration warehouselst.gif

  6. Click OK in the Type Chooser dialog.

  7. Click OK in the Create Variable dialog.

    The Variables dialog updates with the gWarehouseQuotes variable.

    Description of warehouselst2.gif follows
    Description of the illustration warehouselst2.gif

  8. Click OK in the Variables dialog.

6.2.10 Task 10: Add Activities to Obtain a Quote from the InternalWarehouse Process

To add activities to obtain a quote:

  1. Create an invoke activity to invoke the InternalWarehouse BPEL process.

    1. From the Component Palette, drag an Invoke activity into left-side sequence of the switch in the Scope_RetrieveQuotes scope.

      Description of internalwarebp2.gif follows
      Description of the illustration internalwarebp2.gif

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

    4. Drag the mouse from the right side of Invoke_InternalWarehouse to the InternalWarehouse BPEL process.

      Description of internalwarebp3.gif follows
      Description of the illustration internalwarebp3.gif

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

      Element Value
      Name InvokeInternalWarehouse
      Partner Link InternalWarehouseService.internalwarehouseservice_client
      Operation WarehouseRequest

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

      The Create Variable dialog appears for the input variable.

    6. Enter and select the following values:

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

    7. Click OK to close the Create Variable dialog

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

    8. In the Edit Invoke dialog, click OK to save the variable setting.

  2. Assign data to the input variable for the InternalWarehouse process:

    1. Drag an Assign activity from the Component Palette section to above the InvokeInternalWarehouse 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_InternalWarehouseRequest.

    4. Double-click the Assign_InternalWarehouseRequest activity.

      The Assign dialog displays.

    5. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    6. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select the ns4:OrderId node.The namespace number values (for example, ns1, ns2) can vary.
      To  
      • Type
      Variable
      • Variable
      Expand Scope - RetrieveQuote > Variables > lInternalWarehouseInputVariable > payload > WarehouseRequest and select ns1:orderId.

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

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

    8. In the Assign dialog, click OK.

  3. Create a receive activity to receive the delivery date from the internal warehouse:

    1. From the Component Palette, drag and drop a Receive activity below the InvokeInternalWarehouse activity.

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

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

    4. Drag the mouse from the right side of ReceiveInternalWarehouse to the InternalWarehouse BPEL process.

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

      Element Value
      Name Receive_InternalWarehouse
      Partner Link InternalWarehouseService.internalwarehouseservice_client
      Operation WarehouseResponse

    5. Click the Auto-Create Request icon. It is the first icon to the right of the Variable field.

      The Create Variable dialog appears for the input variable.

    6. Enter and select the following values:

      Element Value
      Name linternalWarehouseResponseVariable.
      Global Variable/Local Variable Local Variable, because this variable is not needed for other scopes in the process

    7. Click OK to close the Create Variable dialog.

      The Edit Receive dialog populates with the variable in the Variable field.

    8. In the Edit Receive dialog, click OK to save the variable settings.

  4. Assign data from the lInternalWarehouseResponseVariable variable to the gWarehouseQuotes variable:

    1. Drag an Assign activity from the Component Palette section to below the Receive_InternalWarehouse receive 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_InterWHResponse.

    4. Double-click the Assign_InterWHResponse activity.

      The Assign dialog displays.

    5. From the dropdown list, select Append Operation.

      The Create Append Operation dialog appears.

    6. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_RetrieveQuotes > Variables > lInternalWarehouseResponseVariable > payload and select ns1:WarehouseResponse. The namespace number values (for example, ns1, ns2) can vary.
      To  
      • Type
      Variable
      • Variable
      Expand Variables > gWarehouseQuotes > WarehouseList and select ns1:WarehouseList.

    7. Click OK to close the Create Append Operation dialog.

      The Copy Operation tab in the Create Append Operation dialog updates to show the operation.

    8. In the Assign dialog, click OK.

  5. Click the Collapse (-) icon to minimize the left-side flow sequence.

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

6.2.11 Task 11: Add Activities to Obtain a Quote from the PartnerSupplierMediator Mediator

To add activities to obtain a quote:

  1. Create an invoke activity to invoke the PartnerSupplierMediator mediator:

    1. From the Component Palette, drag an Invoke activity into right-side sequence.

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

    4. Drag the mouse from the right side of Invoke_PartnerSupplier to the PartnerSupplierMediator service.

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

      Element Value
      Name Invoke_PartnerSupplier
      Partner Link PartnerSupplierMediator.PartnerSupplierMediator
      Operation excecute

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

      The Create Variable dialog appears for the input variable.

    6. Enter and select the following values:

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

    7. Click OK to close the Create Variable dialog.

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

    8. In the Edit Invoke dialog, click OK to save the variable setting.

  2. Assign data to the input variable the PartnerSupplierService service:

    1. Drag and drop an Assign activity from the Component Palette section to above the Invoke_PartnerSupplier 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_PartnerRequest.

    4. Double-click the Assign_PartnerRequest activity.

      The Assign dialog displays.

    5. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    6. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable and select ns4:orderInfoVOSDO. The namespace number values (for example, ns1, ns2) can vary.
      To  
      • Type
      Variable
      • Variable
      Expand Scope - RetrieveQuotes > Variables > lPartnerSupplierInputVariable > request and select ns4:orderInfoVOSDO.

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

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

    8. In the Assign dialog, click OK.

  3. Create a receive activity to receive the delivery date from the external partner warehouse:

    1. From the Component Palette, drag a receive activity below the Invoke_PartnerSupplier activity.

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

    4. Drag the mouse from the right side of Receive_PartnerResponse to the PartnerSupplierService service.

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

      Element Value
      Name Receive_PartnerResponse
      Partner Link PartnerSupplierMediator.PartnerSupplierMediator
      Operation callback

    5. Click the Add icon. It is the first icon to the right of the Variable field.

      The Create Variable dialog appears for the input variable.

    6. Enter and select the following values:

      Element Value
      Name lPartnerResponseVariable
      Global Variable/Local Variable Local Variable

    7. Click OK to close the Create Variable dialog.

      The Edit Receive dialog populates with the variable in the Variable field.

    8. In the Edit Receive dialog, click OK to save the variable settings.

  4. Assign data from lPartnerResponseVariable variable to the gWarehouseQuotes variable:

    1. Drag an Assign activity from the Component Palette section to below the Receive_PartnerResponse receive 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_PartnerWHResponse.

    4. Double-click the Assign_PartnerWHResponse activity.

      The Assign dialog displays.

    5. From the dropdown list, select Append Operation.

      The Create Append Operation dialog appears.

    6. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Scope - Scope_RetrieveQuotes > Variables > lPartnerResponseVariable > callback and select ns1:WarehouseResponse. The namespace number values (for example, ns1, ns2) can vary.
      To  
      • Type
      Variable
      • Variable
      Expand Variables > gWarehouseQuotes and select ns1:WarehouseList.

    7. Click OK to close the Create Append Operation dialog.

      The Copy Operation tab in the Create Append Operation dialog updates to show the rule.

    8. In the Assign dialog, click OK.

  5. Click the Collapse (-) icon to minimize the right-side flow sequence.

  6. Click the Collapse (-) icon to minimize the Scope_RetrieveQuotes scope.

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

6.3 Creating the Scope_SelectPreferredSupplier Scope

The Scope_SelectPreferredSupplier scope uses the EvaluatePreferredSupplierRule to select the warehouse with the lowest order total.

To create the Scope_SelectPreferredSupplier scope, perform the following tasks:

6.3.1 Task 1: Create the Scope_SelectPreferredSupplier Scope

The Scope_SelectSupplier scope invokes the RequiresApprovalRule business rule, as shown in Figure 6-6.

Figure 6-6 Scope_SelectSupplier Scope

Description of Figure 6-6 follows
Description of "Figure 6-6 Scope_SelectSupplier Scope"

To add the scope:

  1. From the Component Palette, drag a Scope activity below the Scope_RetrieveQuotes 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_SelectPreferredSupplier.

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

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

6.3.2 Task 2: Add the gPreferredSupplier Variable

In this task, you create the gPreferredSupplier variable, which provides output from the business rule variable com_example_globalcompany_ns_internalwarehouse_WarehouseResponse_o.

To create this variable:

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

    The Variables dialog displays.

  2. Click the Create icon to add a variable.

    The Create Variable dialog displays.

  3. In the Name field, enter gPreferredSupplier.

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

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

  5. Expand Project Schema Files > InternalWarehouse.xsd and select WarehouseResponse. You previously imported this schema file when you created input and output variables for the OrderProcessor BPEL process.

  6. Click OK to close the Type Chooser dialog.

  7. In the Create Variable dialog, click OK.

    The Variables dialog updates with the gPreferredSupplier variable.

  8. Click OK in the Variables dialog.

6.3.3 Task 3: Create the EvaluatePreferredSupplierRule 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 EvaluatePreferredSupplierRule 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. In the Inputs/Outputs section, select the input for the business rule:

    1. From the Add menu, select Input.

      The Type Chooser dialog displays.

    2. Expand InternalWarehouse.xsd and select WarehouseList.

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

  7. 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 Warehouse.xsd and select WarehouseProcessResponse. You previously imported this schema file when you created input and output variables for the ExternalPartnerSupplier BPEL process.

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

  8. Click the Advanced tab and modify the name in the Service Name field to EvaluatePreferredSupplierRule_DecisionService_1. Oracle JDeveloper creates a WSDL for the business rule based on this name.

  9. Click OK to create the business rule.

    The EvaluatePreferredSupplierRule business rule displays in the composite.

    Description of preferredsup2.gif follows
    Description of the illustration preferredsup2.gif

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

6.3.4 Task 4: Reference the RequiresApprovalRule Dictionary in the BPEL Designer

To reference the EvaluatePreferredSupplierRule in the Scope_SelectSupplier scope:

  1. Click the OrderProcessor.bpel tab.

  2. From the Component Palette, drag a Business Rule activity into the Scope_SelectSupplier scope.

    The Business Rule dialog displays.

  3. In the Name field, enter BusinessRule_SelectPreferredSupplier.

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

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

  6. Create input to the business rule, so that the gWarehouseQuotes variable assigns data to input variable com_example_globalcompany_ns_internalwarehouse_WarehouseList_i for the business rule.

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

      The Decision Fact Map dialog displays.

    2. Select the following values:

      Element Value
      From  
      • Type
      Variable
      • Variable
      Expand Variables > gWarehouseQuotes and select ns3:WarehouseList.

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

      To  
      • Type
      Business Rules Facts
      • Variable
      Expand com_example_globalcompany_ns_internalwarehouse_WarehouseList_i and select ns10:WarehouseList.

    3. Click OK.

      The copy operation displays 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_internalwarehouse_WarehouseResponse_o sends data to the gPreferredSupplier variable:

    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. Select the following values:

      Element Value
      From  
      • Type
      Business Rule Facts
      • Variable
      Expand com_example_globalcompany_ns_internalwarehouse_WarehouseResponse_o and select ns1:WarehouseResponse.

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

      To  
      • Type
      Variable
      • Variable
      Expand Variables > gPreferredSupplier and select ns1:WarehouseResponse.

    4. Click OK.

      The copy operation displays in the Assign Output 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.

6.3.5 Task 5: Add a New Rule for Ruleset in Rules Designer

In this task, you add the Rule_FindPreferredSupplier rule. This rule uses the gWarehouseQuotes variable as input, which provides the order total for the warehouses. The logic for the rule selects the warehouse as the current supplier with the lowest order total, as shown in Figure 6-7.

Figure 6-7 Rule_FindPreferredSupplier Rule

Description of Figure 6-7 follows
Description of "Figure 6-7 Rule_FindPreferredSupplier Rule"

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 named Rule_1 displays.

  3. Select Rule_1 and modify the name to Rule_FindPreferredSupplier.

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

  5. For the IF condition, click the left-hand operand and expand WarehouseList > warehouseResponse and select size().

    Description of preferredsup5.gif follows
    Description of the illustration preferredsup5.gif

    1. Click the operator and select >.

    2. Click the right-hand operand and enter 0.

  6. Click the Show Advanced Settings icon:

    Description of preferredsup6.gif follows
    Description of the illustration preferredsup6.gif

  7. Click the Advanced Mode option, which enables you to select advanced actions for the THEN true clause.

  8. For the THEN true clause, perform the following steps to complete the first statement:

    1. Click <insert action> and select assign new.

    2. Click <type> and select int.

    3. Click var and enter index.

    4. Click <expression> and enter 0.

  9. Create the second statement as:

    assign new WarehouseResponse preferredSupplier = new WarehouseResponse()
    
  10. Perform the following steps to complete the third statement:

    1. Click <insert action> and select while.

    2. Click <boolean expression> and enter:

      index < WarehouseList.warehouseResponse.size()
      
    3. Under the while statement, create the following assign new activity:

      assign new WarehouseResponse currentSupplier=(WarehouseResponse)WarehouseList.wareshouseResponse.get(index)
      
    4. Under the while statement, click <insert action> and select if.

    5. Click <boolean expression> and click the Expression Builder icon.

    6. In the Expression Builder, enter the following:

      currentSupplier.orderTotal < preferredSupplier.orderTotal || preferredSupplier.orderTotal <= 0
      

      You can select currentSupplier.orderTotal and preferredSupplier.orderTotal from the Options and click Insert into Expression. Click OK in the Expression Builder.

    7. Under the if statement, click <insert action> and select modify.

    8. Click <target> and select preferredSupplier.

    9. Click <add property>. The Properties dialog displays.

    10. From the Value dropdown menu for deliveryDate, orderTotal, and warehouse, select currentSupplier.deliveryDate, currentSupplier.orderTotal, and currentSupplier.warehouse, respectively.

    11. Click Close in the Properties dialog.

    12. Under the while statement, create the following assign statement:

      assign index = index + 1
      
  11. Create the fourth statement as:

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

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

6.4 Creating the Services and Routing Required for the Scope_FulfillOrder Scope

After a warehouse is selected for an order, the OrderProcessor BPEL process invokes the Scope_FulfillOrder scope, which uses the FulfillOrder mediator service to determine where orders are forwarded for fulfillment. It sends the order to a a file adapter named USPSShipment and a JMS adapter named FulfillmentBatch. For this tutorial, the order is just sent to a JMS queue. There is no consumer of the order data from the queue. This tutorial has you create the JMS adapter, so you can learn how to send messages to a JMS adapter.

Figure 6-8 shows the flow of the FulfillOrder mediator service in the SOA Composite Editor.

Figure 6-8 FulfillOrder Flow

Description of Figure 6-8 follows
Description of "Figure 6-8 FulfillOrder Flow"

Prior to creating the Scope_FulfillOrder scope in the OrderProcessor BPEL process, you create the following:

The tasks to create these elements are as follows:

6.4.1 Task 1: Create USPSShipment File Adapter

The USPSShipment adapter writes order information to a flat file in the C:\tmp directory.

To create this adapter:

  1. Copy LegacyOrderBookingPO.xsd from DEMO_DOWNLOAD_HOME\CompositeServices\OrderBookingComposite\xsd to directory MY_FOD_HOME\OrderBookingComposite\xsd, so you can reference it when you create the adapter.

  2. In the Application Navigator, click the Refresh icon.

  3. From the Component Palette, drag and drop the File Adapter into the right swim lane of the SOA Composite Editor.

    The Adapter Configuration Wizard displays.

  4. Click Next.

    The Service Name page displays.

  5. In the Service Name field, enter USPSShipment, and then click Next.

    The Operation page displays.

  6. In the Adapter Interface page, select Define from operation and schema, and then click Next.

    The Operation page displays.

  7. In Operation Type section, click Write File, and then click Next.

    When you select Write File, the Operation Name is automatically set to Write.

    The File Configuration page displays.

  8. Enter and select the following values:

    Element Value
    Directory for Outgoing Files Click Browse to find the directory where you want the adapter to write the files. For example, you can select /tmp.
    File Naming Convention Specify how you want to name the files. Enter po_%SEQ%.txt. The %SEQ% indicates that the file names are to be numbered sequentially.
    Number of Messages Equals You can leave it at 1, which means that each order writes to a separate file.

  9. Accept the other default settings, and then click Next.

    The Messages page displays.

  10. Click the Browse icon to the right of the URL field.

    The Type Chooser dialog displays.

  11. Expand Project Schema Files > LegacyOrderBookingPO.xsd and select PurchaseOrder.

  12. Click OK to return to the Message page.

    The URL field fills in with value xsd/LegacyOrderBooking.xsd and the Schema Element field fills in with value PurchaseOrder.

  13. Click Next.

    The Finish page displays.

  14. Click Finish.

    The SOA Composite Editor updates with USPSShipment adapter. In addition, the OrderBookingComposite directory updates with files USPShipment_file.jca and USPSShipment.wsdl for the adapter, which you can also see in the Application Navigator.

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

6.4.2 Task 2: Create FulfillmentBatch JMS Service

The FulfillmentBatch JMS adapter sends the order information to a JMS server.

To create this adapter:

  1. From the Component Palette, drag a JMS Adapter from the Service Adapters list into the right swim lane of the SOA Composite Editor.

    The Adapter Configuration Wizard displays.

  2. In the Welcome page, click Next.

    The Service Name page displays.

  3. In the Service Name field, enter FulfillmentBatch, and then click Next.

    The JMS Provider page displays.

  4. From the Oracle Enterprise Messaging Service (OEMS) list, select Oracle WebLogic JMS, and then click Next.

    The Service Connection page displays.

  5. From the Connection list, select the MyAppServerConnection running Oracle SOA Suite, and then click Next.

    The Adapter Interface page displays.

  6. Select Define from operation and schema, and then click Next.

    The Operation page displays.

  7. Select Produce Message, and then click Next.

    The Produce Operation Parameters page displays.

  8. Click the Browse icon next to the Destination Name field.

    The Select Destination dialog displays.

  9. In the Destination section, expand SOAJMSModule and select DemoSupplierTopic, and then click OK.

    The Produce Operation Parameters page displays.

    If you ran the seedFodJmsResource script in Section 2.1.3, "Task 3: Deploy the WebLogic Fusion Order Demo Application," to run the sample application, this topic exists. If topic DemoSupplierTopic is not available, create it through the Oracle WebLogic Server Administration Console, following these procedures:

  10. In the JNDI Name field, enter eis/Jms/TopicConnectionFactory.

    The Messages page displays.

  11. Accept the other defaults in the page, and click Next.

  12. In the Messages page, click option Native format translation is not required (Schema is Opaque), and then click Next.

    The Finish page displays.

  13. Click Finish.

    The SOA Composite Editor updates with FulfillmentBatch adapter. In addition, the OrderBookingComposite directory updates with files FulfillmentBatch_jms.jca and FulfillmentBatch.wsdl for the adapter, which you can also see in the Application Navigator.

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

6.4.3 Task 3: Create FulfillOrder Mediator Service Component

To create the FulfillOrder mediator service component:

  1. From the Component Palette, drag a Mediator service into the designer of the SOA Composite Editor.

    The Create Mediator window appears.

  2. In the Name field, enter FulfillOrder.

  3. From Template, select Interface Definition from WSDL.

  4. Deselect the Create Composite Service with SOAP Bindings.

  5. From the WSDL URL field, generate a WSDL file:

    1. Click the Generate WSDL from schema(s) icon.

      The Create WSDL dialog displays.

    2. In the URL field, click the browse for schema file icon.

      The Type Chooser dialog displays.

    3. Expand Project Schema Files > OrderInfoVOSDO.xsd and select orderInfoVOSDO.

    4. Click OK.

    5. In the Create WSDL dialog, accept the default values for the remaining fields, and click OK.

  6. In the Create Mediator dialog, click OK to create the mediator with the settings.

    Description of fulfillordermed.gif follows
    Description of the illustration fulfillordermed.gif

    The FulfillOrder mediator displays in the SOA Composite Editor.

    Description of fulfillordermed2.gif follows
    Description of the illustration fulfillordermed2.gif

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

6.4.4 Task 4: Create Routing Rules

For the WebLogic Fusion Order Demo application, you create routing rules from the FulfillOrder mediator to the USPSShipment and FulfillmentBatch adapters:

To create a routing rule from the FulfillOrder mediator service to the FullmentBatch JMS adapter:

  1. Drag a wire from the FulfillOrder mediator to the USPSShipment reference handle.

  2. Drag a wire from the FulfillOrder mediator to the FulfillmentBatch reference handle.

    Description of wire6.gif follows
    Description of the illustration wire6.gif

  3. Double-click FulfillOrder to view the Mediator Editor.

    Description of fulfillorder2.gif follows
    Description of the illustration fulfillorder2.gif

  4. Modify the transformation for FulfillmentBatch JMS service:

    1. Click the transformation icon next to the Transform Using field.

      The Request Transformation Map dialog displays.

    2. Select Create New Mapper File and leave the default file entry as orderInfoVOSD_To_opaqueElement.xsl as the file name, and then click OK.

      The Data Mapper displays.

    3. On the Source:FulfillOrderRef.wsdl (left) side, click and drag inp1:orderInfoVOSDO to opaque:opaqueElement on the XSLT File:FulfillmentBatch.wsdl (right) side.

    4. From the Component Palette, expand the String Functions list.

    5. Drag the get-content-as-string function on the top of the mapping and connect the source and target to it.

      This function returns the XML representation of the orderInfoVOSDO input. The Data Mapper dialog should look like the following now.

      Description of mapper4.gif follows
      Description of the illustration mapper4.gif

    6. Click X in the orderInfoVODO_To_opaqueElement.xsl tab to close the Data Mapper.

  5. Modify the transformation for the USPSShipment adapter:

    1. Click the transformation icon next to the Transform Using field.

      The Request Transformation Map dialog displays.

    2. Select Create New Mapper File and leave the default file entry as orderInfoVOSDO_To_PurchaseOrder.xsl as the file name, and then click OK.

      The Data Mapper displays.

    3. On the Source:FulfillOrder.wsdl (left) side, click and drag the following from orderInfoVOSDO to PurchaseOrder on the XSLT File:USPSShipment.wsdl (right) side:

      - OrderId to ID

      - OrderDate to OrderInfo > OrderDate

      - OrderStatusCode to OrderInfo > OrderStatus

      - OrderTotal to OrderInfo > OrderPrice

      - CustomerId to CustID

      - ShipToName to ShipTo > Name > Last

      - ShipToPhoneNumber to UserContact >PhoneNumber

      - Address1 to ShipTo > Street

      - City to ShipTo > City

      - Postalcode to ShipTo > Zip

      - StateProvince to ShipTo > State

      - CountryId to ShipTo > Country

      - OrderItemsInfoVO to Item

      For the OrderItemsInvoVO to OrderItems, the Auto Map Preferences dialog displays. Leave the default settings and click OK.

    4. Click X in the orderInfoVOSDO_To_PurchaseOrder.xsl tab to close the Data Mapper.

    5. Click X in the FulfillOrder.mplan.

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

6.4.5 Task 5: Wire OrderProcessor to FulfillOrder Mediator Service

To wire the OrderProcessor BPEL process to the FulfillOrder mediator:

  1. Drag a wire from OrderProcessor to the FulfillOrder reference handle.

    Description of wire7.gif follows
    Description of the illustration wire7.gif

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

  3. Click the OrderProcessor.bpel tab to see the FulfillOrder mediator service added to the main process.

6.5 Creating the Scope_FulfillOrder Scope

To create the Scope_FulfillOrder scope in the OrderProcessor process, perform the following tasks:

6.5.1 Task 1: Add the Scope_FulfillOrder Scope

To create the Scope_FulfillOrder scope:

  1. From the Component Palette, drag a Scope activity below the Scope_SelectPreferredSupplier 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_FulfillOrder.

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

6.5.2 Task 2: Create the InvokeFulfillOrder Activity

To create an invoke activity to call the FulfillOrder mediator service:

  1. From the Component Palette, drag and drop an Invoke activity into the Scope_FulfillOrder 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 Invoke_FulfillOrder.

  4. Drag the mouse from the right side of Invoke_FulfillOrder activity to the FulfillOrder service.

    Description of fulfillorderbp.gif follows
    Description of the illustration fulfillorderbp.gif

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

    Element Value
    Name Invoke_Fulfillorder
    Partner Link FulfillOrder.FulfillOrder
    Operation execute

  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.

  6. Enter and select the following values:

    Element Value
    Name Modify the name of the input variable to lFulfillOrder_InputVariable.
    Global Variable/Local Variable Select 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. In the Edit Invoke dialog, click OK to save the variable setting.

6.5.3 Task 3: Create the AssignFulfillRequest Activity

To assign data to the input variable for FulfillOrder mediator service:

  1. Drag and drop an Assign activity from the Component Palette section to above the Invoke_FulfillOrder 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_OrderData.

  4. Double-click the Assign_OrderData activity.

    The Assign dialog displays.

  5. From the dropdown menu, select Copy Operation.

    The Create Copy Operation dialog appears.

  6. Select the following values:

    Element Value
    From  
    • Type
    Variable
    • Variable
    Expand Variables > gOrderInfoVariable and select ns4:orderInfoVOSDO. The namespace number values (for example, ns1, ns2) can vary.
    To  
    • Type
    Variable
    • Variable
    Expand Scope - Scope_FulfillOrder > Variables > lFulfillOrder_InputVariable > request and select ns4:orderInfoVOSDO.

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

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

  8. In the Assign dialog, click OK.

  9. Click the Collapse (-) icon to minimize the Scope_FulfillOrder scope.

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

6.6 Creating the Scope_UpdateStatusToComplete Scope for Completed Orders

The Scope_UpdateStatusToComplete scope assigns a status of complete to the order entity variable, which updates the order in the database. If you did not use an entity variable, you would have to create a database adapter.

To create the Scope_UpdateStatusToComplete scope:

  1. Add the Scope_UpdateStatusToComplete scope:

    1. From the Component Palette, drag a Scope activity below the Scope_FulfillOrder 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_UpdateStatusToComplete.

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

  2. Create an assign activity to complete the order:

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

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

    4. Double-click the UpdateOrderStatus activity.

      The Assign dialog displays.

  3. Assign a status of complete for the order:

    1. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      1. Select the XPath Expression Builder icon to display the Expression Builder dialog.
      2. In the Expression box, enter the following:

        string('complete')
        
      3. Click OK to return to the Create Copy Operation dialog.

      To  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > ns4:orderInfoVOSDO and select ns4:OrderStatusCode.

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


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

  4. Assign the order ID to the output variable for the OrderProcessor BPEL process:

    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 > inputVariable > payload > ns4:WarehouseRequest and select ns4:ordeId.

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

      To  
      • Type
      Variable
      • Variable
      Expand Variables > outputVariable > payload > ns3:WarehouseResponse and select Total.

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

  5. In the Assign dialog, click OK.

  6. Click the Collapse (-) icon to minimize the Scope_UpdateStatusToComplete scope.

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

6.7 Creating the Scope_NotifyCustomerofCompletion Scope

The Scope_NotifyCustomerofCompletion scope uses the Oracle User Messaging Service to send an email to the customer when the order is fulfilled.

To create the Scope_NotifyCustomerofCompletion scope:

  1. From the Component Palette, drag a Scope activity below the Scope_UpdateStatusToComplete 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_NotifyCustomerofCompletion.

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

  5. From the Component Palette, drag an Email activity into the empty scope.

    The Email dialog displays.

  6. In the From Account field, leave the default value as Default.

  7. For the To field, specify the customer's email address from the ConfirmedEmail parameter from the gCustomerInfoVariable variable:

    1. Click the XPath Expression Builder icon next to the To field to display the Expression Builder dialog

    2. In the BPEL Variables box, expand gCustomerInfoVariable > parameters > findCustomerInfoVO1CustomerInfoVOCriteriaResponse > result and select ConfirmedEmail.

      The Content Preview box shows:

      bpws:getVariableData('gCustomerInfoVariable','parameters','/ns3:findCustomerInfoVO1CustomerInfoVOCriteriaResponse/ns3:result/ns2:ConfirmedEmail')
      
    3. Click Insert Into Expression.

      The Expression box updates.

    4. Click OK to close the Expression Builder.

  8. For the Subject field, specify Order with id OrderID shipped . To perform the steps:

    1. In the Subject field box, enter Order with id, followed by a space.

      Order with id  
      
    2. Click the XPath Expression Builder icon next to the Subject field to display the Expression Builder dialog.

    3. In the Expression Builder dialog, in the BPEL Variables box, expand gOrderInfoVariable > orderInfoVOSDO and select the OrderID node.

      The Content Preview box shows:

      bpws:getVariableData('gOrderInfoVariable','/ns2:orderInfoVOSDO/ns2:OrderId')
      
    4. Click Insert Into Expression.

      The Expression box updates with the OrderId variable.

    5. Click OK to close the Expression Builder.

    6. Append the end of the Subject field with shipped!. The entire string

      Order with id <%bpws:getVariableData('gOrderInfoVariable','/ns2:orderInfoVOSDO/ns2:OrderId')%> shipped!
      
  9. For the Body field, specify Dear FirstName, your order has been shipped . To perform the steps:

    1. In the Subject field box, enter Dear, followed by a space.

      Dear   
      
    2. Click the XPath Expression Builder icon next to the Subject field to display the Expression Builder dialog.

    3. In the Expression Builder dialog, in the BPEL Variables box, expand gCustomerInfoVariable > parameters > findCustomerInfoVO1CustomerInfoVOCriteriaResponse > result and select FirstName.

      The Content Preview box shows:

      bpws:getVariableData('gCustomerInfoVariable','parameters','/ns3:findCustomerInfoVO1CustomerInfoVOCriteriaResponse')
      
    4. Click Insert Into Expression.

      The Expression box updates with the OrderId variable.

    5. Click OK to close the Expression Builder.

    6. Append the end of the Body field with the following string:

      , your order has been shipped.
      

      The entire string is as follows:

      Dear <%bpws:getVariableData('gCustomerInfoVariable','parameters','/ns6:findCustomerInfoVO1CustomerInfoVOCriteriaResponse/ns6:result/ns4:FirstName')%>,your order has been shipped.
      
  10. Click OK in the Email dialog.

  11. Click the Collapse (-) icon to minimize the Scope_NotifyCustomerofCompletion scope.

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

6.8 Adding a Catch Branch for Incomplete Orders for the Entire Process

Add a catch branch to the process as a whole so that you can update the order status to be canceled in case an error occurs anywhere in the process. Figure 6-9 shows the catches for the OrderProcessor process. The branch on the left is a catch branch, which assigns a status of 'FAULTED' to an order when there is an error. The branch on the right is a catchAll branch, which catches any fault not handled by the catch branch.

Figure 6-9 Catches in OrderProcessor

Description of Figure 6-9 follows
Description of "Figure 6-9 Catches in OrderProcessor"

To create the catches for the process, perform the following tasks:

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

    Description of catchorder.gif follows
    Description of the illustration catchorder.gif

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

  3. Enter the following values:

    Element Value
    Namespace http://www.globalcompany.example.com/ns/OrderBookingService
    Local Part OrderProcessorFault

  4. Click OK in the Catch dialog.

  5. Click the Expand (+) icon to expand the client:OrderProcessorFault catch.

  6. Create an invoke activity to invoke the orderprocessor_client service:

    1. From the Component Palette, drag an Invoke activity into right-side sequence.

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

    4. Drag the mouse from the left side of Invoke_FaultCallbackOPFault to orderprocessor_client.

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

      Element Value
      Name Invoke_FaultCallbackOPFault
      Partner Link orderprocessor_client_ep
      Operation processFault

    5. Click the Browse Variables icon. It is the first icon to the right of the Input field.

      The Variable Chooser dialog appears.

    6. Select the gOrderProcessorFaultVariable and then click OK.

      You created this variable in Section 5.10, "Creating Catch Branches for the Scope_AuthorizeCreditCard."

    7. In the Edit Invoke dialog, click OK to save the variable setting.

  7. In the client:OrderProcessorFault catch, create an assign activity to assign expression 'FAULTED' as input to global variable gOrderInfoVariable.

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

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

    4. Double-click Assign_FaultedStatusToOrder.

      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('FAULTED')
      
      To  
      • Type
      Variable
      • Variable
      Expand Variables > gOrderInfoVariable > orderInfoVOSDO and select OrderStatusCode, which is the variable containing the order information.

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

    8. In the Assign dialog, click OK.

  8. Click the Collapse (-) icon to minimize the client:OrderProcessorFault catch.

  9. Click the Add CatchAll Branch icon for the process to catch any faults that are not handled by client:OrderProcessorFault catch.

    Description of catchorder2.gif follows
    Description of the illustration catchorder2.gif

  10. Expand the CatchAll catch.

  11. Create an invoke activity to invoke the orderprocessor_client service:

    1. From the Component Palette, drag an Invoke activity into right-side sequence.

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

    4. Drag the mouse from the left side of Invoke_FaultCallback to orderprocessor_client.

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

      Element Value
      Name Invoke_FaultCallback
      Partner Link orderprocessor_client
      Operation processFault

    5. Click the Browse Variables icon. It is the first icon to the right of the Input field.

      The Variable Chooser dialog appears.

    6. Select the gOrderProcessorFaultVariable and then click OK.

      You created this variable in Section 5.10, "Creating Catch Branches for the Scope_AuthorizeCreditCard."

    7. In the Edit Invoke dialog, click OK to save the variable setting.

  12. Assign expression ora:getFaultAsString() to global variable gOrderProcessorFaultVariable.

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

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

    4. Double-click Assign_Fault.

      The Assign dialog displays.

    5. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    6. Select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      1. Select the XPath Expression Builder icon.
      2. In the Functions section in the lower right, from the menu, select Advanced Functions and then select getFaultAsString from the menu options.

      3. Click Insert Into Expression, and then click OK to return to the Create Copy Operation dialog.

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

  13. Assign expression ora:getFaultName() to global variable gOrderProcessorFaultVariable.

    1. From the dropdown list, select Copy Operation.

      The Create Copy Operation dialog appears.

    2. Select the following values:

      Element Value
      From  
      • Type
      Expression
      • Expression
      1. Select the XPath Expression Builder icon.
      2. In the Functions section in the lower right, from the menu, select Advanced Functions and then select getFaultName from the menu options.

      3. Click Insert Into Expression, and then click OK to return to the Create Copy Operation dialog.

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

    4. In the Assign dialog, click OK.

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

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