Академический Документы
Профессиональный Документы
Культура Документы
Author
Glenn Stokol
Copyright 2010, Oracle and/or its affiliates. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Editors
Arijit Ghosh Nita Pavitran
Graphic Designer
Rajiv Chandrabhanu
Publisher
Syed Imtiaz Ali
Contents
Practices for Lesson 1 ......................................................................................................... 2 Practice 1-1: Start JDeveloper and Create a Database Connection ................................ 3 Practice 1-2: Create an Application Server Connection ................................................. 5 Practice 1-3: Set JDeveloper Preferences ....................................................................... 8 Practice 1-4: Create a WSIL Connection...................................................................... 12 Practices for Lesson 2 ....................................................................................................... 15 Practice 2-1: Examine Purchase Order XML Schema.................................................. 16 Practice 2-2: Examine soademo Database Tables and Data....................................... 19 Practices for Lesson 3 ....................................................................................................... 20 Practice 3-1: Create the POProcessing Composite ....................................................... 21 Practice 3-2: Add a Transformation to the Mediator Component ................................ 38 Practice 3-3: Deploy and Test the POProcessing Composite Application ................... 43 Practices for Lesson 4 ....................................................................................................... 51 Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name.............. 52 Practice 4-2: Generate and Validate a Configuration Plan ........................................... 59 Practice 4-3: Test a Composite Deployed with a Configuration Plan .......................... 62 Practices for Lesson 5 ....................................................................................................... 68 Practice 5-1: Create the CreditCardValidation SOA Project........................................ 69 Practice 5-2: Create a Database Adapter to Query Credit Cards .................................. 78 Practice 5-3: Deploy and Test the CreditCardValidation Composite........................... 91 Practices for Lesson 6 ....................................................................................................... 93 Practice 6-1: Restructure the POProcessing Assembly Model ..................................... 94 Practice 6-2: Calculate Order Totals with XSL Transformations................................. 99 Practice 6-3: Test the Modified POProcessing Application ....................................... 107 Practices for Lesson 7 ..................................................................................................... 111 Practice 7-1: Add BPEL Components to the POProcessing Assembly Model .......... 112 Practice 7-2: Add Filters to the EnrichPO Mediator Routing Rules........................... 121 Practice 7-3: Design the initial ApproveCCOrder BPEL Process .............................. 126 Practice 7-4: Design the initial Fulfillment BPEL Process......................................... 143 Practice 7-5: Deploy and Test POProcessing with BPEL Components ..................... 150 Practices for Lesson 8 ..................................................................................................... 158 Part 1 ........................................................................................................................... 161 Practice 8-1: Create the CreditCardValidation External Reference ........................... 161 Practice 8-2: Invoke Credit Card Validation from ApproveCCOrder ........................ 165 Part 2 ........................................................................................................................... 180 Practice 8-3: Invoke the Fulfillment Process from ApproveCCOrder........................ 180 Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process ....................... 189 Practice 8-5: Deploy and Test the POProcessing Composite Application ................. 218 Practices for Lesson 9 ..................................................................................................... 230 Practice 9-1: Deploy ADF Application Projects as Services...................................... 232 Practice 9-2: Modify InternalStore with Pick and While Activities ........................... 238
iii
Practice 9-3: Modify OnlineStore with a FlowN Activity.......................................... 264 Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications .............. 273 Practice 9-5: Add a Flow to the Fulfillment BPEL Process ....................................... 286 Practice 9-6: Deploy and Test POProcessing with Stock Checks .............................. 316 Practices for Lesson 10 ................................................................................................... 328 Practice 10-1: Modify CreditCardValidation Composite Assembly Model............... 330 Practice 10-2: Create the CheckCCLimit BPEL Implementation .............................. 341 Practice 10-3: Modify ApproveCCOrder BPEL to Handle Credit Exceptions .......... 354 Practice 10-4: Test CreditCardValidation and POProcessing Exceptions.................. 358
iv
Consider the XML tree structure in the following image of JDevelopers XSLT Mapper:
In the sample image observe that each XML element (the tree nodes below the <sources> root) has an XML namespace prefix, such as imp1: in the image example. The XML namespace prefix, which maps to an XML Namespace string, is: Used to uniquely identify (qualify) each XML element Generated dynamically by the JDeveloper tool that creates the XML structure. When you carry out the practice instructions in this document, dynamically generated XML namespace prefixes for your XML elements may differ from those shown in the screenshots of this document. Note: Therefore, the practice instructions do not specify the XML namespace prefixes for XML elements that you work with, even though the screenshots related to those instructions contain XML namespace prefix values. The screenshots are provided as sample and guide. Your job is to ensure that the XML element names and structures created, mapped, or referenced are correct as documented, and not to be concerned about different XML namespace values.
In this practice, you start JDeveloper and create a database connection. To complete this task, perform the following steps: 1) On the Desktop, double-click the JDeveloper 11g desktop icon to start JDeveloper. Note: The Oracle Database 10g Enterprise Edition server should already be running. If you have connection problems, request for assistance from the instructor. 2) In the JDeveloper window, click the View > Resource Palette menu. 3) On the JDeveloper Resource Palette, click the New icon ( Connection > Database. ) and select New
4) In the Database Connection dialog box, enter the following details: a) Use the IDE Connections option. b) Enter the following field values: Connection Name: Username: Password: Hostname: Port: SID: soademo soademo soademo localhost 1521 XE
Note: The Connection Name value is case-sensitive! c) Select the Save Password option, and accept the default values for the remaining fields. d) Click Test Connection to verify that you can successfully connect to the database, and then click OK.
In this practice, you create an Application Server connection for your SOA Server to enable you to deploy SOA Composite application projects and other services. To complete this task, perform the following steps: 1) Start the WebLogic Administration server by double-clicking the Start WebLogic Admin Server icon on the desktop. Wait until the server is started. You can verify this when you see the text similar to the following display in the terminal window:
<Jun 16, 2009 12:59:43 AM EDT> <Notice> <WebLogicServer> <BEA000360> <Server started in RUNNING mode>
Note: You can ignore the warnings displayed in the command SOA Server command window. 3) In the JDeveloper Resource Palette, click New icon ( Application Server. ) > New Connection >
4) On the Create Application Server Connection wizard pages, enter the information specified in the following table: Step Screen/Page Description a. Create Application Server Connection Step 1 of 5 b. Create Application Server Connection Step 2 of 5 Choices or Values On the Name and Type page enter: Connection Name: soaserver Accept default for other items, and click Next. On the Authentication page enter: Username: weblogic Password: welcome1 Click Next.
2) Start the SOA Server (managed server) by double-clicking the Start SOA Server icon on the desktop. Wait until the server is started. You can verify this when you see the text similar to the following display in the terminal window:
a)
b)
Note: If you require help to perform this task, refer to the following screenshots for guidance to the steps described in the preceding table of instructions:
d)
In this practice, you set some JDeveloper preferences to ensure the settings are compatible for the work being done in the Oracle University network environment. You also learn about some other useful settings. 1) To open the JDeveloper Preferences, select Tools > Preferences from the menu.
2) In the Preferences window, perform the following steps to alter the preferences mentioned: a) For the Environment preference settings, which is the first set of preferences shown when you open the Preferences window, locate the Encoding preference and select UTF-8 from the pull-down box. Use the following image as a guide:
Note: The UTF-8 encoding setting is recommended for ADF-based JSF applications that are generated for use in the Oracle SOA Worklist application to display tasks for assignees in human workflow functionality.
b) In the Preferences window, expand the Code Editor preference (the sixth entry in the navigation tree on the left pane), and click the Line Gutter node. In the Line Gutter settings, select the Show line Numbers option. Use the following image as a guide:
Note: Show Line Numbers displays a line number for each line of source code. This is a useful preference to locate specific lines of code reported for compiler errors and when various design-time tools detect errors in your application code or structures.
c) In the left navigation pane, scroll down and select the Web Browser and Proxy entry. In the Web Browser and Proxy preferences, deselect the Use HTTP Proxy Server check box. Use the following image as a guide:
Note: If you are working with these practices in a non-Oracle University environment then it is likely that you do not have to change this preference. It depends on whether your corporate network proxy allows or denies access to various external URLs in HTTP requests that are used by JDeveloper. 3) In the Preferences window, click OK to apply the selected preference changes. Close the Preferences window.
In this practice, you create a WSIL connection enabling you to look up Web Service and SOA Composite application WSDL URLs from the run-time environment through a WSIL service application predeployed with the installation of Oracle WebLogic Server. Note: Before creating the WSIL connection, you should have disabled the Browser and Proxy settings in JDeveloper Preferences as described in the practice titled Set JDeveloper Preferences." To complete these tasks, perform the following steps: 1) In the JDeveloper Resource Palette window, click the New icon ( Connection > WSIL. ) > New
2) On the WSIL Connection wizard pages, enter the information specified in the following table: Step Screen/Page Description a. Welcome b. Connection Type c. d. e. WSIL URL Authentication Finish Choices or Values Click Next. Accept the default settings. Click Next. WSIL File: http://localhost:8001/inspection.wsil Click Next. Username: weblogic Password: welcome1 Click Next. Click Finish.
Note: Use the following screenshots if you require guidance through the steps described in the preceding table of instructions:
b)
c)
3) To confirm that the WSIL connection is operational, on the Resource Palette expand the WSIL node and expand the WSILConnection1 entry. You should see two subfolders called: soa-infra and usermessagingserver, as shown in the following image:
In addition, you examine the CREDITCARDS table data in the soademo database schema used by the purchase order processing application. The following image represents the JDeveloper Database Navigator window, from which you can browse, modify, and create database structures, as well as query and modify the data they contain:
Note: Familiarization with some of the data and data structures facilitates understanding the application design and implementation tasks performed in subsequent practices.
b) In the Confirm Close Application dialog box, accept the default Close application and remove it from IDE option and click OK.
d) Close the CREDITCARDS page, and soademo page. 4) In the Database Navigator, right-click the soademo connection name, and select Disconnect
5) Click the Application Navigator tab, and optionally close the Database Navigator.
In this practice, you create the POProcessing composite application composed of a Mediator component that routes the purchase order information to a file by using the File Adapter service reference. To complete this task perform the following steps: 1) In the JDeveloper Application Navigator, click New Application.
Note: Use the following screenshots as a guide for the corresponding steps in the table above.
c)
3) The composite.xml file is opened, and select File > Save All to save the changes to your Application and Project.
b.
c. d. e. f. g. h. i. j. a)
Type Chooser Import Schema File SOA Resource Browser Import Schema File Localize Files Type Chooser Create WSDL Create Web Services
Click the Import Schema ( ) icon. Click the Browse Resources icon. Locate the D:\labs\files\xsd folder and select po.xsd, and click OK. With the po.xsd file selected, click OK. Copy Options: Deselect the Maintain original directory structure for imported files option, and click OK. Expand the Project Schema Files > po.xsd entry (if needed), select the PurchaseOrder entry, and click OK. Click OK. Click OK.
Optionally, use the following screenshots as a guide for the steps in the above table:
c)
d)
f)
g)
i)
j)
7) Select File > Save all to save the changes to the project.
b) In the Create Mediator Component window, set the name to RoutePO and select the Define Interface Later template, and click OK.
Note: The Mediator interface is defined by wiring the SOAP service to the Mediator component. The interfaces are implicit. c) Create a wire from the ReceivePO exposed service icon to the RoutePO Mediator icon, by dragging the right-edge arrow icon from the ReceivePO exposed service to the left-edge arrow on the Mediator component. Use the following image as a guide:
9) Select File > Save, or click the Save All icon to save the changes to your application. You now create an external reference for the File Adapter to write the input message structure to a file in the file system.
11) In the composite.xml window, drag a File Adapter component from the Component Palette on to the External References column.
12) On the Adapter Configuration Wizard pages, use instructions in the following table to configure the File Adapter: Step Screen/Page Description a. Welcome b. Service Name c. d. Adapter Interface Operation Choices or Values Click Next. Service Name: WritePOFileService Click Next. Select the Define from operation schema (specified later) option. Click Next. Select the Write File option. Click Next.
Note: If you require help to perform this task, use the following screenshots as a guide for steps in the table: a)
b)
d)
13) On the Adapter Configuration Wizard page, continue to configure the File Adapter WSDL interface by importing the internalorder.xsd XML schema and selecting its order element, by performing the following steps: Step Screen/Page Description a. Messages b. Type Chooser c. d. e. f. g. h. i. Import Schema File SOA Resource Browser Import Schema File Localize Files Type Chooser Messages Finish Choices or Values Click Browse for schema file icon. Click the Import Schema ( ) icon. Click the Browse Resources icon. In the D:\labs\files\xsd folder select internalorder.xsd, and click OK. With the internalorder.xsd file selected, click OK. Copy Options: Deselect the Maintain original directory structure for imported files check box, and click OK. Expand the Project Schema Files > internalorder.xsd entry (if needed), select order, and click OK. Click Next. Click Finish.
Note: If you require help to perform this task, use the following screenshots as a guide for the steps in the preceding table:
b)
c)
e)
f)
h)
i)
14) In the composite.xml file window, verify the File Adapter icon has been added to External References column.
15) Create a wire from the Mediator component to the File Adapter by dragging the rightedge arrow of the Mediator component to the left-edge arrow on the File Adapter icon. Use the following image as a guide:
16) Select File > Save All to save the changes to your project, and verify that your composite application matches the following diagram:
In this practice, you create a transformation on the routing rule added due to wiring the RoutePO Mediator component to the WritePOFileService. An XSL transformation is required to ensure that the PurchaseOrder XML information is correctly copied to the format of the order XML structure required by the files written to disk by the WritePOFileService. To quickly create the transformation map required you use an XML dictionary map file called Order-Dictionary.xml in the XSLT Mapper. To complete this task perform the following steps: 1) In the POProcessing composite.xml window, to edit the Mediator component double-click the RoutePO Mediator icon. Note: Alternatively, right-click the RoutePO Mediator icon and select Edit. operation and click the Select an existing mapper file or create a new one ( icon, next to the Transform Using body: <<Transformation Map>> field. )
3) On the Request Transformation Map dialog box, select the Create New Mapper File option, and click OK.
2) In the RoutePO.mplan window, expand the routing rule section for the execute
c)
e)
Note: At this time, there are no source elements that directly map to the orderPrice, items > inStock, items > item > itemTotals elements in the XSLT File: WritePOFileService.wsdl column. Mappings for these elements are done in a subsequent practice. The for-each construct is automatically inserted for the item element because it is a repeating element. 6) Click the RoutePO.mplan window, and confirm that the Transform Using field shows the new mapping file. Use the following screenshot as a guide:
7) Select File > Save All to save the changes to all files in the project. You can also close the PurchaseOrder_To_order.xsl window.
In this practice, you deploy and test the POProcessing composite application project to the SOA server and use the Enterprise Manager Web application to test the service with a sample input. To complete this task perform the following steps:
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
2) On the SOA Deployment Configuration Dialog, accept default settings and click OK.
3) Since this is the first time you are deploying an application in your JDeveloper session, the Authorization Request window is displayed. Enter weblogic in the Username field, welcome1 in the Password field, and click OK.
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
4) Deployment processing starts. Monitor deployment progress and check for successful compilation in the SOA Log window, and verify that deployment is successful in the Deployment Log window, similar to what is shown in the following images:
In this section you use a Web browser to access the Oracle Enterprise Manager 11g Fusion Middleware Control and initiate a test of the deployed POProcessing application. 5) Log in to Oracle Enterprise Manager 11g Fusion Middleware Control application and open a Web browser by performing the following steps: a) In the Web browser window, enter the URL http://localhost:7001/em. b) On the Oracle Enterprise Manager 11g Fusion Middleware Control login page, enter the User Name weblogic, and Password welcome1, and click Login.
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
a) On the Farm navigation pane, expand the SOA > soa-infra nodes in the tree and click the POProcessing [1.0] link.
7) On the Test Web Service page, scroll down to the Input Arguments section to the Request tab, select XML View and replace the initial XML contents with the XML data in the file D:\labs\files\xml_in\po-medium-ipod.xml. If you require help to replace the initial XML text, use the following steps (or similar): a) With JDeveloper, select File > Open and browse to the D:\labs\files\xml_in folder, select po-medium-ipod.xml and select Open. b) In the JDeveloper po-medium-ipod.xml window, press Ctrl +A to select all the text, and press Ctrl + C to copy the selection to the clipboard.
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
c) On the POProcessing [1.0] Test Web Service page, place the cursor in the XML text area of the Input Arguments, and press Ctrl + A to select all the text and press Ctrl + V to paste it into the XML View replacing the initially supplied XML text. Use the following screenshot as a guide:
d) On the POProcessing [1.0] Test Web Service page, Click Test Web Service.
Note: This action sends the XML data as input message to the POProcessing composite application. It might take several seconds for the page to refresh with the response displayed in the Response tab. Please wait until the page is refreshed.
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
IMPORTANT NOTE: When you click Test Web Service, you may the following saying, Input arguments validation failed and The test was not run as shown in the following image:
If you see the above error dialog box, then perform the following steps to correct and resubmit the data: i) On the Input arguments validation failed dialog box, click OK. ii) On the Request tab, in Input Arguments section modify the contents of XML View field based on the following options: (1) If there is extra space or lines at the end of all the XML data, delete those spaces and lines ensuring the XML data is unaffected, and click Test Web Service, or (2) If there is no extra space or lines at the end of all the XML data, put the cursor or mouse pointer after the last character on the last line of the XML data, press Enter, and click Test Web Service Note: Throughout the rest of the course you may have to repeat this process as required when submitting XML data to initiate tests for each composite application. 8) On the POProcessing [1.0] Response tab page, click the Launch Message Flow Trace link to view the results of the asynchronous composite application.
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
9) On the Flow Trace page, verify that the ReceivePO, RoutePO, and WritePOFileService components have a Completed state indicating the application executed successfully.
10) In a Windows Explorer window, navigate to the D:\labs\podata folder and examine the XML file created for the order. a) Ensure that the order_1.xml file has been created in the podata subfolder, as shown in the following image:
Practice 3-3: Deploy and Test the POProcessing Composite Application (continued)
b) Using JDeveloper open the order_1.xml file to view its contents and verify that the XML file contains similar (if not the same) data in the following image:
c) In the JDeveloper window, close the order_1.xml and the po-mediumipod.xml windows.
You also test the changes to the deployed application and verify that an order data file is created in the new physical directory applied by the configuration plan.
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name
In this practice, you modify the POProcessing composite application and alter the File Adapter to use a logical name instead of an explicit directory for orders written to the file system. You then create a binding property that is to set the directory to the D:\labs directory, and deploy the application using JDeveloper and test the order is written to a file in the labs directory.
Step a.
b. c. d. e. f.
Adapter Configuration Wizard Step 1 of 7 Welcome Adapter Configuration Wizard Step 2 of 7 Service Name Adapter Configuration Wizard Step 3 of 7 Adapter Interface Adapter Configuration Wizard Step 4 of 7 Operation Adapter Configuration Wizard Step 5 of 7 File Configuration
Click Next. Click Next. Click Next. Click Next. Select the Logical Name option Directory for outgoing files (logical name): orderfiles Click Next.
2) In the POProcessing composite.xml window, edit the File Adapter external reference to use a logical name instead of a physical path. Use the following table of instructions as a guide:
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
Step Screen/Page Description Choices or Values
g. h.
Adapter Configuration Wizard Step 6 of 7 Messages Adapter Configuration Wizard Step 7 of 7 Finish
3) To set the path value for the orderfiles logical name perform the following steps: a) In the composite.xml window, click the WritePOFileService external reference icon ensure that the File Adapter reference is selected. b) In the Property Inspector for the Reference WritePOFileService (in the lower right pane in the JDeveloper window), observe that JDeveloper has added a File Adapter reference property called orderfiles for the logical name.
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
c) To set the orderfiles reference property default value to D:\labs, click in the Value cell next to the orderfiles reference property, enter the string value D:\labs and press Enter. Hint: You may wish to resize the Inspector Property window to view and modify the property.
4) Select File > Save All to save the changes to the application.
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
b) In the SOA Deployment Configuration Dialog, select the Overwrite any existing composites with the same revision ID option, and click OK.
c) In the Log window, observe the log messages to ensure that deployment is successful.
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
Use the following image as a guide:
b) While still in the Tree View mode, expand the items field, and in the item field (as shown above) enter the value 1 in the OrderItemTypeArray Size, and click the document icon.
c) Expand the OrderItemTypeArray item and the OrderItemType item and enter the following field values, and then click Test Web Service. productId: productName: price: quantity: SKU102 Test Product 100 1
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
Note: Use the following screenshot as a guide:
11) On the Flow Trace page, verify that the POProcessing composite application instance completed all processing successfully.
10) On the POProcessing [1.0] Response tab page, click the Launch Message Flow Trace link.
Practice 4-1: Modify the POProcessing File Adapter to use a Logical Name (continued)
12) Either using Windows Explorer or JDeveloper, navigate to the D:\labs folder and confirm that a file called order_1.xml has been created in the directory, and open the file to confirm that contains the values entered in the Enterprise Manager Web service test page form fields.
In this practice, you create configuration plan for the POProcessing composite application to replace the destination directory for the orderfiles logical name reference property. After you verify the configuration plan, you redeploy the composite application by using the Enterprise Manager Web interface applying the configuration plan, verify and test the changes.
2) In the Composite Configuration Plan Generator dialog box, accept the default plan file name, and click OK.
Note: The configuration plan file is generated into the project folder, and JDeveloper opens the POProcessing_cfgplan.xml file in its own window. 3) In the POProcessing_cfgplan.xml window, scroll down until you locate the <reference name="WritePOFileService"> element, and append the text \podata to the value D:\labs contained in the <replace> element. The resulting <replace> element should be as follows:
4) Select File > Save All to save the changes to the project files.
6) In the Composite Configuration Plan Validator dialog box, accept the default selection and click OK.
7) In the POProcessing_cfgplan_report.log window, verify that the orderfiles Reference Property is replaced with the new value of D:\labs\podata specified in the configuration plan being validated. Use the following image as a guide:
In this practice, you redeploy the POProcessing composite application using the configuration plan file generated and validated in the previous practice. You also test the deployed application to confirm that the configuration plan changes are applied. To complete these tasks perform the following steps: 1) Return to your Web browser with the Enterprise Manager page, and redeploy POProcessing composite application using the deployment plan file modified in the previous steps. To complete this task perform instructions in the following table Step Screen/Page Description a. Oracle Enterprise Manager SOA > soa-infra Farm tree b. POProcessing [1.0] Redeploy SOA Composite c. File Upload d. e. POProcessing [1.0] Redeploy SOA Composite File Upload Choices or Values
f. g.
POProcessing [1.0] Redeploy SOA Composite POProcessing [1.0] Redeploy SOA Composite
In the Archive or Exploded Directory section, select Archive is on the machine where this Web browser is running option, and click Browse. Navigate to the D:\labs\mywork\POApplication \POProcessing\deploy folder and select the sca_POProcessing_rev1.0.jar file, and click Open. Under the Configuration Plan section, select the Configuration plan is on the machine where this Web browser is running option, and click Browse. Navigate to the D:\labs\mywork\POApplication\POProcessing folder and select the POProcessing_cfgplan.xml file, and click Open. Scroll back to the top (if needed) and click Next. Click Redeploy.
Note: If you require help to perform this task, you can use the following screenshots as a guide to the instructions in the preceding table:
Right-click the POProcessing [1.0] link and select SOA Deployment > Redeploy.
b)
c)
e)
f)
3) In the Definition window, locate the XML <property> element with the name="orderfiles" attribute, and verify that the value is D:\labs\podata, as expected due to redeployment with the configuration plan. Then click OK to close the window.
2) After the redeploy processing window is displayed and closed when the deployment successfully completes, click POProcessing [1.0] link in the Farm navigator tree to view the home page (if needed), and click the Show XML Definition icon.
5) After verifying that the new POProcessing composite application instance completed successfully in the Flow Trace page, use Windows Explorer to verify that the order_1.xml file has been created with supplied data in the D:\labs\podata folder.
Note: There is a chance that more than one XML file may exist in the podata subfolder. If that is the case, then the file with the highest sequence number contains the latest order information.
In this practice, you create a new SOA Project, called CreditCardValidation, in the POApplication workspace, which contains a Mediator component called ValidateCreditCard. To complete this task perform the following steps: 1) In the JDeveloper Application Navigator window, with the POApplication visible in the Application menu, click the Application Menu icon and select New Project.
2) In the New Gallery window, select the SOA Project in the Items list of the Project category, and click OK. 3) In the Create SOA Project Step 1 of 2 Project Name window, enter the Project Name: CreditCardValidation, and click Next. 4) In the Create SOA Project Step 2 of 2 Configure SOA Settings window, select the Composite With Mediator for the Composite Template option, and click Finish.
h.
a)
c)
d)
f)
g)
7) On the Create WSDL > Reply tab page, to define the Reply message structure for the Mediator component WSDL interface, use instructions in the following table as a guide: Step Screen/Page Description a. Create WSDL > Reply b. Type Chooser Choices or Values Click the Browse icon next to the URL field. Expand the Project Schema Files > creditcheck.xsd nodes (if needed) and select the CreditCheckResponse element, and click OK. Click the Fault tab.
c. a)
Create WSDL
c)
8) On the Create WSDL > Fault tab page, to define the Fault message structure for the Mediator component WSDL interface, use instructions in the following table as a guide: Step Screen/Page Description a. Create WSDL > Fault b. Type Chooser Choices or Values Click the Browse icon next to the URL field. Expand the Project Schema Files > creditcheck.xsd nodes (if needed) and select the CreditCheckFault element, and click OK. Click OK.
c.
Create WSDL
b)
c)
9) In the Create Mediator window, to create the Mediator component and its associated exposed service, verify the settings match the following screenshot with the Create Composite Service with SOAP Bindings check box selected, and click OK.
11) In the composite.xml window, verify you initial composite assembly model resembles the following image:
12) Select File > Save All to save your changes to the composite application project.
In this practice, you modify the CreditCardValidation composite application by creating a Database Adapter that queries the CREDITCARDS table using the credit card number supplied as input from the Mediator component. To create and configure the Database Adapter perform the following steps: 1) In the CreditCardValidation composite.xml window, drag a Database Adapter on the External References column.
2) To configure the Database Adapter with the Adapter Configuration Wizard the following instructions: a) Adapter Configuration Wizard Welcome, click Next. Step Screen/Page Description b. Adapter Configuration Wizard Service Name c. Adapter Configuration Wizard Service Connection d. Select IDE Database Connection e. Adapter Configuration Wizard Service Connection f. Adapter Configuration Wizard Operation Type g. h. i. j. k. l. Adapter Configuration Wizard Select Table Import Tables Import Tables Adapter Configuration Wizard Select Table Adapter Configuration Wizard Relationships Adapter Configuration Wizard Attribute Filtering Choices or Values Service Name: CreditCardDBService Click Next. Click the Browse (flashlight) icon next to the connection field. Select the soademo entry, and click Copy Connection. Observe the JNDI Name has the value eis/DB/soademo, and click Next. Select the Perform an operation on a Table option, and ensure the Select check box is selected, and deselect other operations. Click Next. Click Import Tables. Click Query. Copy the CREDITCARDS table from the Available list to the Selected list, click OK. With the CREDITCARDS table listed, click Next. Click Next. Select the creditLimit and status attribute options, deselect remaining options. Note: The cardNumber (key attribute) cannot be deselected. Click Next.
d)
c)
f)
h)
j)
l)
3) While still in the Adapter Configuration Wizard pages, configure the query parameters and selection criteria by using the following table of instructions: Step Screen/Page Description a. Adapter Configuration Wizard Define Selection Criteria b. Parameter Name c. Adapter Configuration Wizard Define Selection Criteria d. Expression Builder e. Expression Builder Choices or Values Next to the Parameters section, click Add. Enter ccNum and click OK. Next to the SQL field, click Edit. Click Add. Form the condition: cardNumber EQUAL ccNum, where: First Argument Query Key: cardNumber
f. g. h. a)
Adapter Configuration Wizard Define Selection Criteria Adapter Configuration Wizard Advanced Options Adapter Configuration Wizard Finish
b)
d)
f)
h)
5) Edit the Mediator component to add transformations, by either right-clicking the Mediator icon and selecting Edit, or double-clicking the Mediator icon. 6) In the ValidateCreditCard.mplan window, for the validateCC operation expand the routing rule created by the wire.
a) In the Request Transformation Map window, click the Create New Mapper File option, accept the default file name supplied, and click OK.
b) In the XSLT Mapper window, map the CCNumber element in the Source column to the ccNum element in the target column, as shown in the following image:
a) In the Reply Transformation Map window, select the Create New Mapper File option, accept the default file name supplied, and click OK.
b) In the XSLT Mapper window, expand the source tree and map the status element in the Source column to the status element in the target column.
10) In the JDeveloper window, close the XSLT Mapper and the ValidateCreditCard.mplan windows.
In this practice, you deploy and test the CreditCardValidation composite application. To complete this task perform the following steps: 1) In the JDeveloper Application Navigator, right-click the CreditCardValidation project entry and select Deploy > CreditCardValidation > to > soaserver. a) In the SOA Deployment Configuration Dialog window, click OK. Note: If you get the Authorization Request window, enter the user name weblogic and password welcome1. b) In the Deployment Log window verify that deployment is successful. 2) In a Web browser window, access the URL http://localhost:7001/em (or return to the page that already has Enterprise Manager SOA page displayed). To perform the first test, login to the Enterprise Manager application (if required) as weblogic with password welcome1. a) On the Farm navigator pane, expand SOA > soa-infra (in needed refresh the page) so that you can see the CreditCardValidation [1.0] entry. Click the CreditCardValidation [1.0] link. b) On the CreditCardValidation [1.0] home page, click Test c) On the Test Web Service page, scroll down the page to the Input Arguments section Request tab and enter the following values: CCNumber: 1234-1234-1234-1234 amount: 1000 Click Test Web Service.
d) Wait for the Response tab to be displayed and verify that the status value returned is VALID, as shown in the following image:
a) On the Request tab page, modify the CCNumber value to be 4321-43214321-4321, leave the amount at 1000, and click Test Web Service.
b) On the Response tab page, verify that the status string value returned is INVALID, as shown in the following image:
3) To perform a second test, to enter another request click the Request tab.
As a result you learn how to: Manage service virtualization and how to restructure a composite assembly model with a new Mediator component and make changes to the component wires without affecting the exposed service (external client interface) Modify the XSL transformation, between the first and second Mediator components, to calculate the item totals. In this case, you reuse and modify the existing XSL Transformation. Create a new XSL Transformation, in the routing rule between the second Mediator and the WritePOFileService, to calculate the order total using the item totals already calculated by the XSL transformation between the Mediator components. Note: There are multiple solutions for calculating the item and order totals. One solution exists that uses a single XSL file without the need for an additional Mediator component. However, the single XSL file approach involves a higher degree of complexity and a detailed knowledge of XSL constructs, which can only be coded in the XSLT Mapper source and not visually constructed. Since the detailed explanation of the XSL constructs involved (call-template and recursion) is not in the scope of this course, the design approach used was chosen for its simplicity and the ability to provide a context in which you can learn to use the various capabilities in the composite application assembly model and work with additional XSL functions visually.
In this practice, you restructure the POProcessing composite application assembly model by adding a new Mediator component between the RoutePO Mediator component and the WritePOFileService. This requires deleting the existing routing rule (wire) between the RoutePO and WritePOFileService, adding a new Mediator component, and creating the wires needed to complete the application assembly model. To complete this task perform the following steps: 1) In the JDeveloper Application Navigator, open the composite.xml file in the POProcessing project by double-clicking the composite.xml file name. Note: If required, expand the POProcessing project and its SOA Content folder to locate the composite.xml file.
d) In the Confirm Delete dialog box, click Yes. e) In the JDeveloper window, click the composite.xml tab and verify that the wire between the RoutePO and WritePOFileService has been removed. Use the following image as a guide:
Insert and Wire a new Mediator Component between RoutePO and WritePOFileService
3) In the composite.xml window, create a new Mediator component called EnrichPO using the One-Way Interface template, and set the Input (type) as the order element in the internalorder.xsd project XML Schema. Note: Ensure the Create Composite Service with SOAP Bindings check box is deselected. If you require help to perform this task, use the table of instructions and associated screenshots: Step Screen/Page Description composite.xml a. b. Create Mediator Choices or Values Drag a Mediator component from the component palette into the Components column. Name: EnrichPO Template: One-Way Interface
Note: Deleting a routing rule from a Mediator component deletes the associated wire from the composite.xml file. However, deleting the wire from the composite.xml removes the target service from the associated Mediator routing rule, that is, a routing rule is not deleted when its associated wire is deleted.
c. d. a)
b)
d)
4) In the composite.xml window, create two wires to form the next phase of the composite application assembly model, using the following image as a guide:
Note: If you require help to perform this task, use the following steps to accomplish the task:
b) In the composite.xml window, drag a wire from the EnrichPO Mediator Drag to add a new Reference icon ( ) to the service interface icon ( WritePOFileService external reference.
) of the
5) In the JDeveloper window, select File > Save All to save the changes to all files in the project.
In this practice, you modify an existing XSL Transformation to calculate the item totals for order item when the data is being routed to the second Mediator component. In addition, you create a new XSL transformation for the new Mediator component. The new XSL Transformation copies the internal order items and calculates the order total from the item totals before the transformed data is sent to other services, such as the WritePOFileService. To complete these tasks perform the following steps:
a) In the composite.xml window, double-click the RoutePO Mediator component to open the Mediator Editor. b) In the RoutePO.mplan window, under the Routing Rules section in the Static Routing for the execute operation, click the Select an existing mapper file or create a new one. Icon ( ). c) In the Request Transformation Map dialog box, accept the Use Existing Mapper File (default) option, and click the Browse Mappings icon ( ). d) In the SOA Resource Browser window, select the PurchaseOrder_To_order.xsl file and click OK. e) In the Request Transformation Map window, confirm the Use Existing Mapper File field contains the value xsl/PurchaseOrder_To_order.xsl and click OK.
f) In the RoutePO.mplan window, confirm your changes to the XSL mapper file have been applied, and select File > Save to save the changes. 2) Close the RoutePO.mplan window.
1) Edit the RoutePO Mediator component and use the existing PurchaseOrder_To_order.xsl file for the routing rule. If you require help to perform this task, use the following steps:
3) Modify the PurchaseOrder_To_order.xsl file to set the itemTotal for each item element by multiplying the price and quantity. In addition, initialize target elements that are not mapped from a source element. Use instructions in the following table and associated screenshots as a guide: Step Screen/Page Description a. JDeveloper Applications Navigator Choices or Values Expand the POProcessing > SOA Content > xsl folder, and double-click the PurchaseOrder_To_order.xsl file. PurchaseOrder_To_order.xsl Expand the items and item nodes in both the source and target columns, and drag a multiply component, from the Mathematical Functions in the Component Palette, to the middle column of the XSLT Mapper. PurchaseOrder_To_order.xsl Drag the price from the source column onto the left-side handle of the multiply function in the middle column of the XLST Mapper. Drag the quantity element to the multiply function. PurchaseOrder_To_order.xsl Drag the right-side handle (the result) from the multiply function to the itemTotal in the target column. a)
c.
d.
b.
c)
d)
Step Screen/Page Description Choices or Values PurchaseOrder_To_order.xsl Right-click the orderTotal in the a. target column, and select Set Text > Enter Text. b. Set Text Select the Text option, and enter the value 0.0. Click OK. PurchaseOrder_To_order.xsl c. Verify the value 0.0 is assigned as text to the orderTotal element in the target column. a)
b)
5) In the PurchaseOrder_To_order.xsl window, initialize the orderTotal to a value of 0.0 by using instructions in the following table and associated screenshots:
6) In the PurchaseOrder_To_order.xsl window, initialize the items > inStock element to the value true by using instructions in the following table and associated screenshots: Step Screen/Page Description Choices or Values PurchaseOrder_To_order.xsl Right-click the inStock in the a. target column, and select Set Text > Enter Text. b. Set Text Select the Text option, and enter the value: true. Click OK. PurchaseOrder_To_order.xsl Verify the value true is c. assigned as text to the inStock element in the target column. a)
b)
c)
7) Select File > Save to save the changes to the PurchaseOrder_To_order.xsl file, and close the PurchaseOrder_To_order.xsl window.
Oracle SOA Suite 11g: Build Composite Applications 103
b) In the EnrichPO.mplan window, under the Routing Rules section in the Static Routing for the execute operation, click the Select an existing mapper file or create a new one. Icon ( ). c) In the Request Transformation Map window, select the Create New Mapper File option, accept the default XSL file name order_To_order.xsl, and click OK.
Note: The order_To_order.xsl file is opened in the XSLT Mapper visual design window. 2) In the order_To_order.xsl window, to map all elements in the source to their corresponding elements in the target, perform the following steps: a) Click and drag a line connecting the order element in the source column to the order in the target column.
b) In the Auto Map Preferences window, accept the default settings and click OK. c) In the order_To_order.xsl window, verify that all the elements have been mapped by expanding all the child nodes.
Oracle SOA Suite 11g: Build Composite Applications 104
a) In the composite.xml window, double-click the EnrichPO Mediator component to open the Mediator Editor.
c) Drag a line from the itemTotal (expanding the items > item element, if required) from the source on to the left-side handle of the sum function in the middle column.
d) Drag a line from the right-side handle of the sum function to the orderTotal element in the target column.
In this practice, you deploy and test the modified POProcessing composite application.
a) In the JDeveloper Application Navigator window, right-click the POProcessing project and select Deploy > POProcessing > to > soaserver. b) In the SOA Deployment Configuration dialog box, accept all the default settings and select the Overwrite any existing composites with the same revision ID check box. Click OK. Note: If the Authorization Request dialog box is displayed, enter the user name weblogic and password welcome1, and click OK. c) On the Deployment Log window, confirm that deployment is successful. 2) In a Web browser window, if needed enter the URL http://localhost:7001/em and login with the user name weblogic and password welcome1. 3) Test the updated POProcessing composite application, which writes order files in the D:\labs\podata folder, by using Oracle Enterprise Manager with instructions in the following table: Step Screen/Page Description a. Enterprise Manager home b. c. POProcessing [1.0] POProcessing [1.0] Test Web Service Choices or Values Expand the SOA folder in the Farm navigation tree, and click the POProcessing [1.0] link. Click Test. In the Input Arguments Request tab section, select the XML View option, and replace the supplied XML data with the contents of the D:\labs\files\xml_in\po-mediumipod.xml file (using copy and paste techniques). Note: Ensure you delete any trailing spaces from the XML payload before clicking Test Web Service.
Click Test Web Service. Note: If you require help to perform this task, use these screenshots as a guide for instructions in the preceding table:
b)
c)
4) After verifying that the new POProcessing composite application instance completed successfully in the Flow Trace page.
5) In Windows Explorer, verify that the order_2.xml file has been created with supplied data in the D:\labs\podata folder.
Note: There is a chance that more than one XML file may exist in the podata subfolder. If that is the case, then the file with the highest sequence number contains the latest order information.
After modifying the assembly model you edit the following two BPEL process components and create their structure with their initial Scope, Assign, and Transform activities: 1. The ApproveCCOrder BPEL process that validates the credit card and is later modified to include human workflow to manually approve orders if their total exceeds 3000. 2. The Fulfillment BPEL process that performs processing tasks to fulfill approved orders. Fulfillment processing includes checking if stock (inventory) for the order is available from an internal and online store, selecting the store to supply the products for an order, and sending the order to a shipping company. The tasks required to change the assembly model include: Adding the two BPEL components Adding the wires between components, and modifying the EnrichPO Mediator component with routing rules that use filters to route paypal orders to the WritePOFileService and Fulfillment BPEL process, and credit orders to the ApproveCCOrder BPEL process. Adding a wire from the ApproveCCOrder BPEL process to the Fulfillment BPEL process to ensure credit card orders that are approved are fulfilled.
In this practice, you modify the POProcessing assembly model, by adding two BPEL Process components and implementing the wires for the required interactions.
Add and wire the ApproveCCOrder BPEL component into the POProcessing assembly model as shown in the following image:
To complete these tasks perform the following steps: 1) In the JDeveloper Application Navigator, expand the POProcessing project and double-click the composite.xml file under the SOA Content folder. Note: If the composite.xml file is already open you do not perform this step. 2) In the composite.xml window, to add a new BPEL component, drag the BPEL Process icon from the Component Palette into the Components column.
3) In the Create BPEL Process window, configure the BPEL Process by using instructions in the following table and associated screenshots: Step Screen/Page Description a. Create BPEL Process Choices or Values Name: ApproveCCOrder Deselect the Expose as a SOAP service check box Accept default values for other fields. Next to the Input field, click the Browse Input Elements icon ( ).
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
Step Screen/Page Description b. Type Chooser c. d. e. Create BPEL Process Type Chooser Create BPEL Process Choices or Values Expand the Project Schema Files > internalorder.xsd, select order and click OK. Next to the Output field, click the Browse Output Elements icon ( ). Expand the Project Schema Files > internalorder.xsd, select order and click OK. Verify that the Template is set to Asynchronous BPEL Process, that the Input and Output elements have {http://www.example.org/ns/intorder}order as their value, and that the Expose as a SOAP service option is not selected, and click OK.
a)
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
b)
c)
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
d)
e)
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
4) To create a wire between the EnrichPO Mediator component and the ApproveCCOrder BPEL component, click and drag the Drag to add a new Reference icon ( ) on the right edge of the EnrichPO Mediator component to the left edge service interface icon ( ) of the ApproveCCOrder BPEL component.
5) Verify that your composite.xml assembly model resembles the following image:
6) Click File > Save All to save changes to all files in the POProcessing project. In this section, you add the Fulfillment BPEL Process component to the composite application assembly model, and create wires from the EnrichPO Mediator component and the ApproveCCOrders BPEL process to the Fulfillment BPEL process. Use the following image as a guide:
To complete these changes to the assembly model, perform the following steps: 7) In the composite.xml window, to add a new BPEL component drag the BPEL Process icon from the Component Palette into the Components column. 8) In the Create BPEL Process window, configure the following field values: Name: Fulfillment
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
Template: Asynchronous BPEL Process Deselect the Expose as a SOAP service check box {http://www.example.org/ns/fulfillment}Fulfill Input: mentRequest {http://www.example.org/ns/fulfillment}Fulfill Output: mentResponse
Accept default values for all the other fields. Note: To set the Input and Output elements use their respective browse icons, and import the D:\labs\files\xsd\fulfillment.xsd the first time you browse for an element. Use the following screenshot as a guide for the Create BPEL Process configuration:
Note: Only if you require help to perform this task, use instructions in the following table (without associated screenshots) to configure fields in the Create BPEL Process window: Step Screen/Page Description a. Create BPEL Process Choices or Values Name: Fulfillment Deselect the Expose as a SOAP service check box Input: Click the Browse Input Elements icon ( ). Click the Import Schema File icon ( ). Click the Browse Resources icon ( ).
b. c.
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
Step Screen/Page Description d. SOA Resource Browser e. Import Schema File Choices or Values Navigate to the D:\labs\files\xsd folder, select fulfillment.xsd, and click OK. URL: file:/D:/labs/files/xsd/fulfil lment.xsd With Copy to Project check box selected. Click OK Copy Options: Ensure you deselect both the Maintain original directory structure for imported files and the Rename duplicate files check boxes, as follows:
f.
Localize Files
g. h. i. j.
Type Chooser Create BPEL Process Type Chooser Create BPEL Process
Click OK. Expand the Project Schema Files > fulfillment.xsd, select FulfillmentRequest and click OK. Output: Click the Browse Output Elements icon ( ) Expand the Project Schema Files > fulfillment.xsd, select FulfillmentResponse and click OK. Verify the following settings: Template: Asynchronous BPEL Process Input: {http://www.example.org/ns/ful fillment}FulFillmentRequest Output: {http://www.example.org/ns/ful fillment}FulFillmentResponse Ensure the Expose as a SOAP service check box is not selected. Click OK.
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
9) In the composite.xml window, verify that your assembly model includes the stand-alone Fulfillment BPEL process. Use the following screenshot as a guide:
10) To create a wire from the EnrichPO Mediator component to the Fulfillment BPEL component, click and drag the Drag to add a new Reference icon ( ) from the right edge of the EnrichPO Mediator component to the left edge service interface icon ( ) of the Fulfillment BPEL component.
11) To create a wire from the ApproveCCOrder BPEL component to the Fulfillment BPEL component, click and drag the Drag to add a new Reference icon ( ) from the right edge of the ApproveCCOrder BPEL component to the left edge service interface icon ( ) of the Fulfillment BPEL component.
Practice 7-1: Add BPEL Components to the POProcessing Assembly Model (continued)
12) Verify that your composite.xml assembly model resembles the following image:
13) Click File > Save All to save changes to all files in the POProcessing project.
To complete these tasks perform the following steps: 1) In the POProcessing composite.xml window, to edit the routing rule definitions of the EnrichPO Mediator double-click the EnrichPO Mediator component icon.
In this practice, you modify the EnrichPO Mediator component and modify the following routing rules with the target service: WritePOFileService::Write: You add a filter to check if the input <payMethod> has the string paypal. Only paypal orders are sent to the WritePOFileService. The XSL Transformation is already configured for this rule. ApproveCCOrder/approveccorder_client::process: You add a filter to check if the input <payMethod> has the string credit. Only credit card orders are sent to the ApproveCCOrder BPEL process. In this case, you use the same XSL Transformation file configured for the WritePOFileService routing rule. Fulfillment/fulfillment_client::process: You add a filter to check if the input <payMethod> has the string paypal. Paypal orders must still be routed to the Fulfillment BPEL process to ship products and complete the order cycle. In this case, you need to create a new XSL Transformation to calculate the order total, and cannot reuse the order_To_order.xsl file, because the target XSD has different parent element to the order element.
Practice 7-2: Add Filters to the EnrichPO Mediator Routing Rules (continued)
a)
b)
3) On the JDeveloper menu, click File > Save All, or click the Save All icon ( JDeveloper toolbar.
)on the
Add a Credit Filter and Reuse an XSL file in the Second Routing Rule
4) In the EnrichPO.mplan window, in the second routing rule (with the ApproveCCOrder/approveccorder_client::process target service) add a filter that checks if the input message payMethod element is equal to the 'credit' string value. Use the following substeps: a) In the EnrichPO.mplan window, in the routing rule with the ApproveCCOrder/approveccorder_client::process target service, click the Invoke Expression Builder icon ( ). b) In the Expression Builder window, in the Variables section, expand the in > request > order tree, select payMethod, and click Insert Into Expression.
Practice 7-2: Add Filters to the EnrichPO Mediator Routing Rules (continued)
c) In the Expression Builder window, in the Expression field append ='credit' to the XPath expression for payMethod to form the following expression (or similar): $in.request/inp1:order/inp1:payMethod = 'credit' Click OK. 5) In the EnrichPO.mplan window, in the second routing rule (with the ApproveCCOrder/approveccorder_client::process target service) add an XSL Transformation. Use the following substeps: a) In the EnrichPO.mplan window, in the routing rule with the ApproveCCOrder/approveccorder_client::process target service, click the Select b) In the Request Transformation Map window, use the Use Existing Mapper File option (the default), and click the Browse Mappings icon ( ). c) In the SOA Resource Browser window, select the order_To_order.xsl file from the project XSL folder, and click OK. d) In the Request Transformation Map window, with the Use Existing Mapper File field set to xsl/order_To_order.xsl, click OK.
Note: In this case, we are using an existing XSL file because it meets with the requirements for this routing rule source and target element structures. 6) On the JDeveloper menu click File > Save All, or click the Save All icon ( JDeveloper toolbar. ) on the
Add a PayPal Filter and New XSL File to the Third Routing Rule
7) In the EnrichPO.mplan window, in the third (and last) routing rule (with the Fulfillment/fulfillment_client::process target service) add a filter that checks if the input message payMethod element is equal to the 'paypal' string value. Use the following substeps: a) In the EnrichPO.mplan window, in the routing rule with the Fulfillment/fulfillment_client::process target service, click the Invoke Expression Builder icon ( ).
).
Practice 7-2: Add Filters to the EnrichPO Mediator Routing Rules (continued)
b) In the Expression Builder window, in the Variables section, expand the in > request > order tree, select payMethod and click Insert Into Expression. c) In the Expression Builder window, in the Expression field append ='paypal' to the XPath expression for payMethod to form the following expression (or similar): $in.request/inp1:order/inp1:payMethod = 'paypal' Click OK. 8) In the EnrichPO.mplan window, add a new XSL Transformation to the third routing rule with Fulfillment/fulfillment_client::process as its target service. Use the following substeps:
).
b) In the Request Transformation Map window, select the Create New Mapper File option, and accept the default Mapper File Name order_To_FulFillmentRequest.xsl and click OK. c) In the order_To_FulFillmentRequest.xsl window, map all elements by dragging the order element from the sources tree on to the FulfillmentRequest element in the target tree. d) In the Auto Map window, accept all the default settings and click OK. e) In the order_To_FulFillmentRequest.xsl window, delete the map line connecting the orderTotal elements. f) In the order_To_FulFillmentRequest.xsl window, to calculate the orderTotal correctly, perform the following mapping actions: i) Drag a Sum function from the Mathematical Functions group in the Component Palette into the middle column of the window. ii) Expand the source tree until you see the itemTotal, in the items > item child nodes, and drag the itemTotal to the left-side handle on the Sum function in the middle column.
a) In the EnrichPO.mplan window, in the routing rule for Fulfillment/fulfillment_client::process, click the Select an existing mapper file or
Practice 7-2: Add Filters to the EnrichPO Mediator Routing Rules (continued)
iii) Drag the right-side handle of the Sum function in the middle column to the orderTotal in the target column. Use the following image as guide to your final mapping results:
g) Select File > Save All to save the transformation map file and EnrichPO.mplan file changes. 9) Close the EnrichPO.mplan and order_To_FulFillmentRequest.xsl windows.
To create the process flow shown requires that you perform the following tasks: Create an Assign activity to copy the received order data into the process output variable. The output variable is used as working copy of data that is updated with changes to the order as it flows through the process. Create the validatecc Scope to contain activities that interact with the credit card validation composite application service. Initially this scope contains an Empty activity. Create the fulfillment Scope to contain activities that interact with the Fulfillment BPEL process. In this scope you create local BPEL variables used to interact with
Additional Note: You can use either of the following ways to rename BPEL activities: Double-click the activity name, enter the new name, and press Enter. Double-click the activity icon, replace the name in the General tab, and click OK. For brevity, subsequent instructions just ask you to rename the activity and do not spell out the specific steps to rename an activity. To create the initial ApproveCCOrder BPEL process flow, perform the following steps:
Note: If you require help to create the process flow in the ApproveCCOrder.bpel window, perform the following steps:
the Fulfillment service and a Transform activity to prepare the input data that is required by the Fulfillment BPEL process. Note: A hybrid development and design approach is being followed for creating the course application. With a hybrid approach you do some top-down process assembly and structural design with the visual designers, and fill in the implementation details later. However, you continue to develop and deploy other smaller composite applications, such as the CreditCardValidation composite application, and Web services that are required as external service to complete the POProcessing application. In addition, because the next lesson teaches how to invoke other services from a BPEL process, you do not implement activities to invoke external services from BPEL in this practice. Invoking other services from BPEL is covered in the lesson titled Orchestrating Services with BPEL and its associated practices.
a) Drag an Assign activity from the BPEL Activities on the Component Palette into the BPEL process flow.
c) Drag a Scope activity from the Component Palette into the flow after the assign activity.
e) Drag another Scope activity from the Component Palette into the flow after the Scope_validatecc activity.
3) Select File > Save to save the changes to the ApproveCCOrder BPEL Process. In this section, you edit the Assign activity and create a copy operation to store a working copy of the order from the inputVariable in the outputVariable. 4) In the ApproveCCOrder.bpel window, to edit the activity and add copy operations double-click the Assign_orderinfo activity. Note: Alternatively, you can right-click the Assign_orderinfo activity and select Edit.
Note: Editing an Assign activity causes the Copy Operation tabbed page of the Assign activity to be displayed. 5) In the Assign window, create a copy operation that copies the order XML structure from the (global) inputVariable to the outputVariable. Use instructions in the following table and associated screenshots as a guide: Step Screen/Page Description a. Assign > Copy Operation Choices or Values Click the Add icon ( Operation. ) and select Copy
c.
Assign
a)
Note: Because namespace prefixes such as the ns2: (before the order element in variable tree as seen in image associated with this step) can differ, they are excluded from the instructions. Confirm the addition of the copy operation in the row below the From and To headings, and click OK.
Note: When you select an element in a variable tree structure you are creating an XPath expression for that element that is added to the BPEL source code in the associated activity XML element attribute values. The XPath expression helps the BPEL Engine extract the XML fragment or value and copy it to the target element. c)
6) Select File > Save to save the changes to the ApproveCCOrder BPEL Process. In this section, you expand the scope and add an Empty activity into the scope. The Empty activity is used as a placeholder for other process activities that are added in the
Oracle SOA Suite 11g: Build Composite Applications 132
practices for the lesson titled Orchestrating Services with BPEL. The Empty activity is required in this practice so that we can successfully compile and deploy the composite application that contains the BPEL process. 7) In the ApproveCCOrder.bpel window, to expand Scope_validatecc activity, click its Expand icon ( ). Note: You must first expand a scope to add activities into its structure.
9) Confirm that the scope contains the Empty_1 activity as shown in the following image, and to collapse the Scope_validatecc activity, click its Collapse icon ( ).
8) Drag an Empty activity from the Component Palette into the Scope_validatecc activity, and drop it on to the text Drop Activity Here within the expanded scope.
In this section, you expand the Scope_fullfilment activity and add two local variables called fulfillmentRequest and fulfillmentResponse, respectively. The two variables are used by activities that are added to interact with the Fulfillment BPEL process in the practices for the lesson titled Orchestrating Services with BPEL. After creating the variables you create a Transform activity in the scope to populate the fulfillmentRequest variable with the request data. 11) In the ApproveCCOrder.bpel window, expand the Scope_fulfillment activity. 12) In the expanded Scope_fulfillment activity, on the left-hand edge click the Variables icon ( ). The Variables window is displayed.
13) In the Variables window, create the fulfillmentRequest variable and set its type to the FulfillmentRequestMessage type defined in the project fulfillment.wsdl file. Use instructions in the following table and associated screenshots as a guide: Step Screen/Page Description a. Variables b. Create Variable Choices or Values Click the Create icon ( ). Name: fulfillmentRequest Type: Select the Message Type option and click the Browse Message Types icon ( ). Expand the Message Types > Project WSDL Files > Fulfillment.wsdl > Message Types folder, select the FulfillmentRequestMessage, and click OK. Confirm the following field settings: Name: fulfillmentRequest Type: Select the Message Type option Message Type: (without the namespace)
c.
Type Chooser
d.
Create Variable
a)
b)
d)
14) In the Variables window, confirm that the fulfillmentRequest variable has been added to the list of variables. Note: Do not close the Variables window, as you need to create a second variable in the same window.
15) In the Variables window, create the fulfillmentResponse variable and set its type to the FulfillmenResponseMessage type defined in the project fulfillment.wsdl file. Use instructions in the following table as guide (no screenshots are provided): Step Screen/Page Description a. Variables b. Create Variable Choices or Values Click the Create icon ( ). Name: fulfillmentResponse Type: Select the Message Type option and click the Browse Message Types icon ( ). Expand the Message Types > Project WSDL Files > Fulfillment.wsdl > Message Types folders, select the FulfillmentResponseMessage, and click OK. Confirm the following field settings: Name: fulfillmentResponse Type: Select the Message Type option Message Type: (without the namespace) FulfillmentResponseMessage. Click OK.
c.
Type Chooser
d.
Create Variable
Note: The fulfillmentRequest and fulfillmentResponse variables are defined to have message structures compatible with the Fulfillment BPEL process interface, because their message types are obtained from the WSDL file created for the Fulfillment BPEL Process component interface. 17) Select File > Save to save the changes to the ApproveCCOrder BPEL Process. In this section you create a Transform activity to copy the contents of the outputVariable into the fulfillmentRequest local variable. Therefore the Transform activity must be added inside the scope to access the fulfillmentRequest variable. Note: The children elements of each variable are the same; therefore, the transformation map is quickly created by mapping the parent elements and using the Automap tool to complete the XSL mapping required. 18) In the ApproveCCOrder.bpel window, create and edit a Transform activity inside the Scope_fulfillment activity. Use the following steps: a) Drag a Transform activity from the Component Palette onto the text Drop Activity Here in the expanded Scope_fulfillment activity.
c) To edit the Transform activity, right-click the Transform_fulfillment activity icon, and click Edit. Note: Alternatively, double-click the Transform activity icon.
Step Screen/Page Description a. Transform > Transformation b. c. Source Variable Transform > Transformation
Choices or Values Next to the Source section, click the Create icon ( ). Source Variable: Select outputVariable Source Part: payload is already selected Click OK. Target Variable: fulfillmentRequest (should already be selected. If not select it) Target Type: payload (should also be selected) Mapper File: xsl/Transformation_to_fulfillment Click the Create Mapper File icon ( ). Note: The XSL file is created and opened in the XSLT Mapper Editor window.
19) Configure the transformation source variable as the outputVariable payload, and the target variable as the fulfillmentRequest payload and create a new transformation map file called Transformation_to_fulfillment. Use instructions in the following table and associated screenshots as a guide:
b)
20) In the Transformation_to_fulfillment.xsl window, create the mappings rules such that all elements in the source are mapped to their respective target elements by performing the following steps: a) Drag the order element in the source column to the FulfillmentRequest element in the target column. b) In the Auto Map Preferences window, accept all default settings and click OK. c) Confirm that all elements in the source are mapped to their respective elements in the target by expanding the child node. Use the following image as a guide:
In this practice, you design the high-level business Fulfillment BPEL process flow using Scope activities. The implementations of activities for each Scope are completed in subsequent practices of this course. One of the objectives is to learn how to construct a BPEL Process skeleton or framework which models a process flow and to add the implementation details later, after dependent services have been constructed. The following image illustrates the initial structure of the Fulfillment BPEL Process component:
Your tasks are to create the following scopes: The insertorder Scope, for inserting an approved order into the database by using Entity Variables in the practices for the lesson titled Managing Transactions with Services. At this time, this scope is created with an Empty activity. The checkstock Scope, for invoking the stock checking services in a parallel flow as covered in the lesson titled Implementing Coordination and Interaction Patterns. At this time, this scope is created with an Empty activity.
Oracle SOA Suite 11g: Build Composite Applications 143
In this section you create and name three Scope activities to structure the BPEL process. 3) In the Fulfillment.bpel window, in the BPEL process diagram between the receiveInput and callbackClient activities create three named Scope activities called (in the order listed here): Scope_insertorder, Scope_checkstock, and Scope_shiporder. Use the following image as a guide:
Note: If you require help to perform this task, in the Fulfillment.bpel window use the following steps:
2) In the composite.xml window, double-click the Fulfillment BPEL Process component icon to open it in the BPEL Editor window.
a) Drag a Scope activity from the Component Palette and drop it between the receiveInput and callbackClient activities. Rename the scope to Scope_insertorder. b) Drag a Scope activity from the Component Palette and drop it after the Scope_insertorder activity. Rename the new scope to Scope_checkstock. c) Drag a Scope activity from the Component Palette and drop it after the Scope_checkstock activity. Rename the new scope to Scope_shiporder.
4) Save the changes to your project. At this stage of the implementation there is nothing to process in Scope_insertorder and Scope_checkstock. However, to successfully compile and deploy the composite with this BPEL process you add an Empty activity into each scope. To complete this task perform the following steps: 5) Expand the Scope_insertorder activity, and using the following screenshot as a guide drag an Empty activity from the Component Palette into the scope.
6) Expand the Scope_checkstock activity, and using the following screenshot as a guide drag an Empty activity from the Component Palette into the scope.
7) Collapse each of the Scope activities and save the changes to your project. In this case, you initialize the response data in the outputVariable with hard-coded string that are later replaced with dynamic results. This section enables you to learn how to create two copy operations in the same Assign activity. 8) In the Fulfillment.bpel window, expand the Scope_shiporder, drag an Assign activity into the scope, and rename the Assign activity to Assign_shipstatus. Use the following image as a guide:
9) To edit and configure copy operations in the Assign_shipstatus activity, double-click the Assign_shipstatus activity icon. On the Assign > Copy Operations tabbed page, create the following two copy operations:
Note: If you require help to create the copy operation, perform the following steps: i) On the Assign > Copy Operations tabbed page, click the Add icon ( select Copy Operation. ) and
ii) In the Create Copy Operation window, in the From section select Expression as the Type, and in Expression enter: 'none' (including the single quotes). iii) In the Create Copy Operation window, in the To section select Variable as the Type, expand Process > Variables > ouputVariable > payload > FulfillmentResponse and select shipStatus. iv) Click OK.
Note: If you require help to create the copy operation, perform the following steps: i) On the Assign > Copy Operations tabbed page, click the Add icon ( select Copy Operation. ) and
ii) In the Create Copy Operation window, in the From section select Expression as the Type, and in Expression enter: 'none' (including the single quotes). iii) In the Create Copy Operation window, in the To section select Variable as the Type, expand Process > Variables > ouputVariable > payload > FulfillmentResponse and select carrier. iv) Click OK.
10) On the Assign > Copy Operations tabbed page, verify that the operations are configured and click OK.
11) Collapse the Scope_shiporder activity, and close the Fulfillment.bpel window, and save the changes to the POProcessing project.
To complete the testing tasks, perform the following steps: 1) Using JDeveloper, deploy the POProcessing project to the soaserver connection. When the SOA Deployment Configuration Dialog window is displayed select the Overwrite any existing composites with the same revision ID. check box. Note: Enter the login weblogic and welcome1 credentials in an Authorization Request window, if it is displayed. Monitor the Messages Log and Deployment Log windows to ensure the composite application is successfully deployed. If not, correct the errors and repeat this step. 2) Open a Web browser window, and enter the Oracle Enterprise Manager URL http://localhost:7001/em, and if necessary login with Username: weblogic with Password: welcome1. 3) On the Oracle Enterprise Manager home page, locate and click the deployed POProcessing [1.0] composite application link (located under the SOA tree in the Farm navigation pane).
In this practice, you deploy the modified POProcessing composite application project, and perform the following two tests: Test an order that uses the paypal payment method. This test is designed to check that paypal orders are sent to the Fullfilment and WritePOFileService and not processed by the ApproveCCOrder BPEL component. Test an order that uses the credit payment method, which is designed to check that credit card orders flow through the ApproveCCOrder and Fulfillment BPEL Process components and not the WritePOFileService. In addition, you examine the results of executing Assign and Transform activities by using Oracle Enterprise Manager to view BPEL component details in the Audit Trail and Flow tabs of the Flow Trace page.
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
Test POProcessing with a PayPal Order
4) On the POProcessing [1.0] page, initiate the first test with the D:\labs\files\xml_in\po-small-guitar.xml file copied into the Request > XML View text area and replace the <payOption> element value with paypal. Use the image as a guide:
Note: If you require help to perform this task, use the following substeps: a) On the POProcessing [1.0] page, click Test. b) On the Request tabbed page, in the Input Arguments section select XML View and delete the supplied text. c) Open the D:\labs\files\xml_in\po-small-guitar.xml in JDeveloper (or Notepad) and copy all the text into the Input Arguments (XML View) text area in the Web browser page. d) In the XML View text area, replace the <ns0:payOption>credit</ns0:payOption> element with <ns0:payOption>paypal</ns0:payOption>. e) Click Test Web Service.
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
5) On the Response tab, click the Launch Message Flow Trace link.
6) On the Flow Trace page, under the Trace section confirm that the message flowed through ReceivePO, RoutePO, EnrichPO and then to WritePOFileService and Fulfillment. Use the following image as a guide:
7) On the Flow Trace page, to examine the Fulfillment BPEL Process in the Audit Trail tabbed page click the Fulfillment link in the Instance column of the Trace tree and answer the following questions: a) What is the value of the <orderTotal> element in the inputVariable? b) Describe the steps to find the orderTotal in the inputVariable. c) On the Flow tabbed page, what is the value of the <carrier> element after the first copy operation is executed in the Assign_shipstatus activity? d) Describe how you located the value for the <carrier> element. e) On the Flow tabbed page, what is the title of the window that displays activity information? f) On the Flow tabbed page, how can you examine the value of the response message? g) How do you return to the Flow Trace page for the composite application instance? Table of Answers for step 7 Step Answer a. The <orderTotal> element of the inputVariable contains the string value 690.
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
Step Answer b. On the Audit Trail tabbed page, expand the <payload> entry under the receiveInput activity:
c.
The <carrier> element is an empty XML element, for example <carrier/> after the first copy operation is executed in the Assign_shipstatus activity, as shown in the following image:
d. e.
Note: The Activity Details window shows the changes to the outputVariable after each copy operation is executed. The top entry is the first copy operation. In this case, two copy operations are executed by the Assign_shipstatus activity. On the Flow tabbed page, scroll down the visual flow and click the Assign_shipstatus activity icon. Activity Details
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
Step Answer f. On the Flow tabbed page, click the callbackClient icon. For example:
g.
Note: Since this process is an asynchronous BPEL process the callbackClient activity holds the response data. The last activity in a synchronous process is a Reply activity. One-way processes do not have an activity to return a response message. Click the Flow Trace link in the breadcrumb path at the top of the Flow Trace page.
8) Close the Flow Trace page, which is a pop-up window, so that you can return to the POProcessing [1.0] Response tabbed page in Oracle Enterprise Manager. 9) Click the Request tab to prepare for the next test. 10) In a Windows Explorer window, navigate to the D:\labs\podata folder and verify that the order was written to a file called order_4.xml (or XML file with the highest sequence number). Open the file and verify that the <orderTotal> element contains the string value 690, and <payMethod> contains the string paypal. Close the application and window that you used to display the contents of the XML file.
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
Test POProcessing with a Credit Order
11) On the POProcessing Composite page, if needed click the Request tab to initiate the second test with the D:\labs\files\xml_in\po-small-guitar.xml file copied into the Input Arguments (XML View) text area. Use the image as a guide:
Note: This time leave the <payOption> value as credit. Do not change any text in the input. If you require help to perform this task, use the following substeps: a) On the Request tabbed page, select XML View and delete the supplied text. b) Open the D:\labs\files\xml_in\po-small-guitar.xml in JDeveloper (or Notepad) and copy all the text into the Request tabbed page > XML View text area, replacing any text already in the field. c) Click Test Web Service. 12) On the Response tab, click the Launch Message Flow Trace link.
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
13) On the Flow Trace page, examine the Trace tree that should resemble the following flow:
a) Did the WritePOFileService get executed? Explain your answer. b) Remember that the ApproveCCOrder is wired to the Fulfillment BPEL process. Now, can you explain why the Fulfillment BPEL process did not execute? Table of Answers for Step 13 Step Answer a. No, the WritePOFileService did not execute. The reason is because the filters in the EnrichPO Mediator component routes orders with payOption=credit to the ApproveCCOrder BPEL Process and not the WritePOFileService. b. A wire in the composite assembly model is not an invocation pattern. A wire in an assembly model represents a possible interaction pattern. Although the ApproveCCOrder BPEL process contains a Partner Link (a reference) to the Fulfillment BPEL Process service interface, it does not have activities to invoke the BPEL process. 14) On the Flow Trace page, click the ApproveCCOrder link and use the Audit Trail or Flow tabbed pages to answer the following questions: a) What change has been made by the Assign_orderinfo activity? b) Expand the payload containing the fulfillmentRequest variable for the Transform_fulfillment activity. Alternatively, on the Flow page click the Transform_fulfillment activity icon to display the variable contents in the Activity Details window. Have all the item elements from the outputVariable (the order) been copied to the fulfillmentRequest variable? Explain your answer. c) What sequence of activities enabled the fulfillmentRequest variable to obtain its values? d) Is it possible for the values in the fulfillmentRequestVariable to differ from those stored in the inputVariable? Table of Answers for Step 14 Step Answer a. The outputVariable has obtained a copy of all elements received by the inputVariable when the BPEL process was executed.
Oracle SOA Suite 11g: Build Composite Applications 156
Practice 7-5: Deploy and Test POProcessing with BPEL Components (continued)
Step Answer b. Yes, all item elements for the order have been copied to the fulfillmentRequest variable. The for-each XSL construct in the XSL Transformation used ensures that repeating elements, such as the item element, are copied to the target XML structure. Note: An Assign activity would require a copyList operation or need to use the copyList XSL function to accomplish similar results. c. The Assign_orderinfo activity first copied the order elements from the inputVariable to the outputVariable, and the Transform_fulfillment activity used a transformation to copy the outputVariable values to the fulfillmentRequest variable. d. Yes. If the outputVariable, which is being used as a working copy of the order data, was modified after it was assigned its data in the Assign_orderinfo and before the Transform_fulfillment activity is executed the data in the fulfillmentRequest variable can differ from the inputVariable. Note: At this stage, the BPEL process does not modify the outputVariable before it is copied to the fulfillmentRequest variable. 15) Close the Flow Trace Web browser window.
The changes to the POProcessing composite application assembly model include: The ValidateCCService external reference and the wire connecting it to the ApproveCCOrder BPEL Process component. The three JMS Adapter external references (USPS JMSAdapter, UPS JMSAdapter, FedEx JMSAdapter) and the wires connecting each of them to the Fulfillment BPEL Process component.
In part one the following image illustrates the changes you make to the ApproveCCOrder BPEL Process component:
The changes made to the ApproveCCOrder BPEL Process include: Invoking the synchronous CreditCardValidation composite application as a service. This requires that you create an external reference or partner link for the CreditCardValidation service. Checking the result of credit card validation by using a Switch activity. If the card is valid, then you restructure the ApproveCCOrder to place the Fulfillment scope in the <case> branch of the Switch activity. Invoking the asynchronous Fulfillment BPEL component and receive its callback message. In this case, the Fulfillment partner link has already been created, in the ApproveCCOrder BPEL process, from a wire created between the ApproveCCOrder and Fulfillment components in the practices for lesson 7. In part two the following image shows the changes implemented in the Fulfillment BPEL process:
Creating three partner links, one for each reference to a JMS Adapter representing the service for shipping companies. The JMS Adapters for the three shipping companies (UPS, USPS, and FedEx) are created as External References in the composite application or Partner Links in the BPEL process component. Adding a Switch activity to check the shipMethod element of the inputVariable and select a different JMS Adapter service to invoke based on its value. Note: This choice of shipping company service to be invoked is later changed to a business rules implementation. Invoking the different JMS Adapters within branches of the Switch activity.
To complete these tasks, perform the following steps: 1) On the JDeveloper Application Navigator, open the POProcessing composite.xml file, if it is not already open.
Note: If it helps use the following steps to fill in the Create Web Service window: a) In Name enter ValidateCCService, and accept default Type value of Reference. b) To the right of the WSDL URL field, click the Find Existing WSDLs icon ( open the SOA Resource Browser window. ) to
c) In the SOA Resource Browser window, select the Resource Palette option from the pull-down menu, expand the Application Server > soaserver > SOA > CreditCardValidation [1.0] (soa_server1) entry, select ValidateCreditCard_ep and click OK.
d) In the Create Web Service window, the WSDL URL is populated with your selection from the SOA Resource Browser window and the Port Type is populated with the validateCC_ptt option, which is the only possible value for this service endpoint. Click OK to create the external reference.
4) In the composite.xml window, verify that the external reference icon has been added as shown in the following image:
As shown in the above image, you can verify the partner link is created if you open the ApproveCCOrder.bpel file, which can be done by double-clicking the ApproveCCOrder.bpel file (in the Application Navigator) or the double-clicking ApproveCCOrder BPEL Process component icon. 6) Verify that your composite application, shows the addition of the ValidateCCService external references wired to the ApproveCCOrder BPEL Process component, as shown in the following image,
7) Save the changes to your composite application and the ApproveCCOrder BPEL component.
In this practice, you edit the ApproveCCOrder BPEL process to implement activities for credit card validation in the Scope_validatecc. The following image shows the resulting changes to the BPEL process flow:
Note: The changes made to the BPEL Process include adding the following activities into Scope_validatecc: An Assign activity to supply the credit card validation request data An Invoke activity to initiate a synchronous validateCC operation of the ValidateCCService A Switch activity to check the response returned by the service. In the Switch activity: o The Scope_fulfillment is dragged into the <case> branch after you configure its condition expression to checks for a VALID return string from the validateCC operation o An Assign activity is created in the <otherwise> branch to set the order status to indicate the credit card is invalid. To complete this task, perform the following steps:
1) Open the ApproveCCOrder BPEL Process component file in the BPEL Editor. Note: You may already have the BPEL file open due to verifying the presence of the ValidateCCService partner link in step 5) of the previous practice in this lesson titled Create the CreditCardValidation External Reference. In this section you create the typical activity flow for a synchronous service invocation, which contains an Assign activity followed by an Invoke activity. What occurs after the Invoke activity depends on how the response data is used by the process. In this case, you check the results with Switch activity. Note: The Invoke activity is configured first because it creates the variable needed for the Assign activity that is added before the Invoke activity. 2) In the ApproveCCOrder.bpel Design window, locate and expand the Scope_validatecc activity, and delete the existing Empty activity contained within the scope. In the Confirm Delete window, click Yes. 3) In the ApproveCCOrder.bpel Design window, inside the Scope_validatecc activity create three named activity types in the order that they are listed in the following table: Activity Type a. Assign b. Invoke c. Switch Activity name Assign_ccinfo Invoke_validatecc Switch_ccvalid Purpose Assign credit card number to the credit card validation service request variable. Invoke the credit card validation service. Check the response from the credit card validation service.
Note: Use the following image as a guide to the resulting process flow within the
If you require help to perform the task of constructing the flow inside the Scope_validatecc activity, perform the following steps: a) Drag an Assign activity from the Component Palette into the expanded Scope_validatecc activity. b) Double-click the Assign activity name and rename it to Assign_ccinfo. c) Drag an Invoke activity from the Component Palette and drop it inside Scope_validatecc after the Assign_ccinfo activity. d) Double-click the Invoke activity name and rename it to Invoke_validatecc. e) Drag a Switch activity from the Component Palette and drop it inside Scope_validatecc after the Invoke_validatecc. f) Double-click the Switch activity name and rename it to Switch_ccvalid. 4) Save the changes to your BPEL process. In this section, you first configure the Invoke activity to invoke the ValidateCCService, which involves linking the Invoke activity with ValidateCCService partner link and creating variables to communicate the request data and receive the response.
Note: The Edit Invoke window is opened when you perform this step. 6) In the Edit Invoke window, when opened already contains the correct Name, Partner Link, and Operation field settings, because there is only one operation provided by the service. To automatically configure variables that supply the request (input) and response (output) data for the service invocation, use instructions in the following table and associated screenshots: Step Screen/Page Description a. Edit Invoke Choices or Values On the right of the Input field, click the Automatically Create Input Variable icon ( ) Note: Creating a variable in this way ensures the variable has the correct XML message structure for the service request. Accept the default variable name, select the Local Variable option, and click OK.
b.
Create Variable
a)
b)
Note: The default naming convention applied by JDeveloper is to construct the variable name by concatenating the activity name with an underscore and the operation name an underscore and the string InputVariable. The string OutputVariable is used at the end for output variables (responses).
d)
Note: When you click OK the Errors indicator should be removed, provided you have correctly configured the Invoke activity settings. 7) Save the changes to the BPEL process. Now that the input variable has been created for the Invoke activity, you can populate the input variable with the credit card data needed to perform the validateCC operation provided by ValidateCCService. 8) To populate the input variable for the Invoke_validatecc activity, edit the Assign_ccinfo activity and create the following two copy operations:
a) Copy the cardNumber element in the order element of the process inputVariable to the CCNumber element of the CreditCheckRequest in the Invoke_validatecc_validatecc_inputVariable. Note: Remember you created Invoke_validatecc_validatecc_inputVariable as local variable in Scope_validatecc. Use the following screenshot as a guide:
b) Copy the orderTotal element in the order element of the process inputVariable to the amount element of the CreditCheckRequest in the Invoke_validatecc_validatecc_inputVariable. Use the following image as a guide:
c) In the Assign window, verify that your two copy operations have been created and click OK.
9) Save the changes to your BPEL process. In this section, configure the Switch <case> condition to check if the response message received through the Invoke_validatecc activity contains the string VALID.
12) In the Condition Expression window, click the XPath Expression Builder icon (
13) In the Expression Builder window, create an XPath expression that compares if the status element in the Invoke_validatecc_validateCC__OutputVariable > reply > CreditCheckResponse tree is equal to the string literal uppercase value 'VALID'. Use the following image as a guide:
Click OK after building the complete Expression shown. 14) In the ApproveCCOrder.bpel Design window, verify your condition is correctly shown and click outside the Condition Expression window:
Note: It is easier to drag the Scope when it is in the collapsed state. However, the BPEL Editor expands the Scope_fulfillment activity after it is dropped in the <case> branch. 17) Save the changes to your BPEL process. In this section, configure the activity sequence in the Switch <otherwise> branch to execute an Assign activity that sets the outputVariable status element to indicate that the credit card is not valid.
20) Edit the Assign_invalidcc activity and create one copy operation, which copies the literal string expression invalid credit card to the status element in the outputVariable process variable. Use the following image as a guide:
21) In the Assign window, verify the copy operation is created and listed and click OK.
In this practice, you expand the Scope_fulfillment activity and create an activity sequence for an asynchronous invocation pattern to invoke the Fulfillment BPEL Process for orders with a valid credit card. You use an Assign activity copy the response from the Fulfillment service to the order status in the outputVariable. The response value completed indicates the order has been shipped. The status value waiting indicates some or all the ordered products are out of stock and cannot be shipped. Note: Remember you have already created the fulfillmentRequest and fulfillmentResponse variables in the scope for interaction (exchanging input and output data, respectively) with the Fulfillment BPEL process. Therefore when you configure the Invoke activity you browse for and use the existing variables instead of automatically creating new variables. In addition, the Scope_fulfillment activity contains a Transform activity that has already initialized the input data in the fulfillmentRequest variable. To complete this task perform the following steps: 1) In the ApproveCCOrder.bpel Design window, if needed, expand the Scope_fulfillment activity in the <case> branch of the Switch_validatecc activity. In this section you create Invoke, Receive, and Assign activities to form the sequence needed to asynchronously interact with the Fulfillment BPEL process.
2) In the ApproveCCOrder.bpel Design window, after the Transform_fulfillment activity add the three named activity types in the sequence shown in the following table: Activity Type a. Invoke b. Receive c. Assign Activity Name Invoke_fulfillment Receive_fulfillment Assign_fulfillment_status
Note: Use the following image as a visual aid to the layout and sequence of the activities in the Scope_fulfillment activity:
If you require help to create the flow, then perform the following steps: a) Drag an Invoke activity into Scope_fulfillment and drop it after the Transform_fulfillment activity. Rename the Invoke activity to Invoke_fulfillment. b) Drag a Receive activity into Scope_fulfillment and drop it after the Invoke_fulfillment activity. Rename the Receive activity to Receive_fulfillment. c) Drag an Assign activity into Scope_fulfillment and drop it after the Receive_fulfillment activity. Rename the Assign activity to Assign_fulfillment_status. 3) Save the changes to your BPEL Process
c. d.
e.
Invoke
Note: An alternative way to do steps a) and b) is to drag a line connecting the rightedge Invoke Settings icon from the Invoke_fulfillment activity to the Fulfillment partner link. However, the table of instructions is suggested to avoid scrolling the window to accommodate the drag and drop approach. a)
c)
e)
9) In the Edit Receive window, browse for and select fulfillmentResponse for the Variable to receive the response data from the Fulfillment service. Hint: Click the Browse Variables icon ( ), and in the Variable Chooser and select the fulfillmentResponse variable in the nest Scope called Scope_fulfillment. Use the following image as a guide to the Invoke activity settings:
The Fulfillment BPEL service returns a shipStatus and carrier response values. In this section you configure the Assign activity to copy the shipStatus from the fulfillmentResponse to the process outputVariables order > status element. 10) In the ApproveCCOrder.bpel Design window, double-click the Assign_fulfillment_status activity to edit the activity and add a copy operation.
11) Configure the Assign_fullfillment_status activity with a copy operation that copies the shipStatus from the fulfillmentResponse variable to the outputVariable order > status element. Use the following image as a guide:
12) Verify that your Scope_fulfillment activity sequence resembles the following image:
13) Save the changes to your BPEL process and project. Note: You have mostly completed the main end-to-end flow for the ApproveCCOrder process. The next practice enables you to construct the core flow pattern for the Fulfillment BPEL process. After this lessons practices, you update and change the BPEL process flow (and composite application) implementation to include business rules and human workflow patterns where applicable.
In this practice, you modify the Fulfillment BPEL Process by creating and configuring three JMS Adapter partner links, one for each shipping company: UPS, USPS, and FedEx. The following image shows how you modify the process flow with a Switch to check the shipMethod chosen by the customer and create the order shipping request message for an invoke activity for each JMS Adapter:
To complete these tasks perform the following steps: 1) In the POProcesing composite.xml window, double-click the Fulfillment BPEL Process component icon, to open it in the BPEL Editor.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
a) On the Component Palette, click the BPEL Services pane to expose the adapter component icons, among others.
b) In the Fulfillment.bpel Design window, drag the JMS Adapter from the Component Palette into the right-hand Partner Link column. Note: This opens the Adapter Configuration Wizard window.
3) In the Adapter Configuration Wizard window, step through the pages to configure the JMS Adapter for the UPS shipping company by using instructions in the following table and associated screenshots: Step Screen/Page Description a. Welcome b. Service Name Choices or Values Click Next. Service Name: UPSJmsService Click Next.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Step Screen/Page Description c. JMS Provider Choices or Values Select the Oracle Enterprise Messaging Service (OEMS) option and the Oracle WebLogic JMS option from the pull-down menu. Click Next. Connection exists in: Select the Resource Palette option Connection: soaserver Click Next. Accept the default Define operation and schema (specified later) option Click Next. Operation Type: Select the Produce Message option. Operation Name: Accept the default value of Produce_Message Click Next. Destination Name (Queue): jms/demoFulfillmentQueue JNDI Name: eis/demo/Queue Accept default settings for other fields. Click Next. Note: To set the Destination field click Browse and select the queue name from the Select Destination window. Manually change the JNDI Name as specified. URL: xsd/fulfillment.xsd Schema element: ShippingRequest Click OK when done. However, first read the following note: Note: To set these values click the Browse icon ( ) next to the URL field and in the Type Chooser select the ShippingRequest element under the Project Schema files > fulfillment.xsd. Click Next. Click Finish.
d.
Server Connection
e. f.
g.
h.
Messages
i.
Finish
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
a)
b)
c)
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
d)
e)
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
f)
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
g) To select the Destination click Browse next to the Destination Name (Queue) field and on the Select Destination window, scroll down and select demofulfillmentQueue under the SOAJMSModule folder, and click OK.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Enter the correct JNDI Name value (eis/demo/Queue), which is already configured in the run-time environment:
h) On the Messages page, click the Browse icon ( ) to display the Type Chooser where you can select the ShippingRequest element from the internalorder.xsd (either nested in the fulfillment.xsd or the Project Schema Files folders):
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
i)
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
4) In the Create Partner Link window, which is displayed after completing the steps in the Adapter Configuration Wizard, accept the default settings as shown in the following image and click OK:
5) In the Fulfillment.bpel Design window, confirm that the partner link for the JMS Adapter exists in the Partner Link column the right-side of the window.
6) Click on the POProcessing composite.xml window, and observe that a wire has been created between the Fulfillment BPEL Process component icon and the newly added UPSJmsService external reference icon. Use the following image as guide:
Note: This should remind you that when creating a partner link in a BPEL process it changes the assembly model in the associated composite.xml file with the addition of the external reference wired to the BPEL component in which the partner link is created. 7) Save the changes to your BPEL process
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
8) In the Fulfillment.bpel Design window, create a JMS Adapter partner link and using the Adapter Configuration Wizard configure the second JMS Adapter as the USPS service by using instructions in the following table (no screenshots are provided): Step Screen/Page Description a. Welcome b. Service Name c. JMS Provider Choices or Values Click Next. Service Name: USPSJmsService Click Next. Select the Oracle Enterprise Messaging Service (OEMS) option and the Oracle WebLogic JMS option from the pull-down menu. Click Next. Connection exists in: Select the Resource Palette option. Connection: soaserver Click Next. Accept the default Define operation and schema (specified later) option. Click Next. Operation Type: Select the Produce Message option. Operation Name: Accept the default value of Produce_Message Click Next. Destination Name (Queue): jms/demoFulfillmentQueue JNDI Name: eis/demo/Queue Accept default settings for other fields. Click Next. URL: xsd/fulfillment.xsd Schema element: ShippingRequest Note: If you click the Browse icon to select the schema element, then click OK. Click Next. Click Finish. Click OK.
d.
Server Connection
e. f.
g.
h.
Messages
i. j.
9) Save the changes to your BPEL process. 10) In the Fulfillment.bpel Design window, create a JMS Adapter partner link and using the Adapter Configuration Wizard configure the third JMS Adapter as the FedEx service by using instructions in the following table (no screenshots are provided):
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Step Screen/Page Description a. Welcome b. Service Name c. JMS Provider Choices or Values Click Next. Service Name: FedExJmsService Click Next. Select the Oracle Enterprise Messaging Service (OEMS) option and the Oracle WebLogic JMS option from the pull-down menu. Click Next. Connection exists in: Select the Resource Palette option Connection: soaserver Click Next. Accept the default Define operation and schema (specified later) option Click Next. Operation Type: Select the Produce Message option Operation Name: Accept the default value of Produce_Message Click Next. Destination Name (Queue): jms/demoFulfillmentQueue JNDI Name: eis/demo/Queue Accept default settings for other fields. Click Next. URL: xsd/fulfillment.xsd Schema element: ShippingRequest Note: If you click the Browse icon to select the schema element, then click OK. Click Next. Click Finish. Click OK.
d.
Server Connection
e. f.
g.
h.
Messages
i. j.
11) Save the changes to the BPEL process and to the POProcesing composite application.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
12) In the POProcessing composite.xml window, verify that the assembly model resembles the following image:
Note: The Fulfillment BPEL Process component has three wires, where each wire is linked to a different JMS adapter external reference. Remember, you could have also created and configured the JMS Adapters as external references in the composite.xml and wired them to the Fulfillment BPEL Process component to yield the same results. In this section you create the activity sequence in the Scope_shiporder that uses a Switch with three <case> branches to determine which JMS service is used to send the shipment request for an order based on the shipMethod value in the FulfillmentRequestMessage structure in the inputVariable. You then set the correct response values for the status and selected carrier in the FulfillmentResponseMessage structure of the outputVariable. 13) In the Fulfillment.bpel Design window, expand the Scope_shiporder activity. Note: On the Component Palette, you might need to click the BPEL Activities and Component pane to expose the BPEL activities needed for the next set of steps.
Add a Switch to Choose the JMS Adapter for the Shipment Request
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
14) In the Fulfillment.bpel Design window, in the Scope_shiporder activity add a Switch activity named Switch_shiporder at the beginning of the scope. Ensure the Switch has three <case> branches, and move the existing Assign_shipstatus activity into the <otherwise> branch as shown in the following image:
Note: Only if you require help to create the flow sequence in the Scope_shiporder activity, perform the following steps: a) Drag a Switch activity as the first activity in Scope_shiporder. b) Rename the Switch activity Switch_shiporder. c) Expand the Switch_shiporder activity. d) To the left of the Switch_shiporder activity icon, click the Add Switch Case icon ( ) twice to create two new <case> branches:
e) Drag the Assign_shipstatus activity into the <otherwise> branch. 15) Configure first <case> branch name and condition expression for the UPS service by performing the following steps: a) On the left-most <case> branch, to edit the branch name and expression, doubleclick the text <case> shown in the <case> branch title bar (in the grey heading with the <case> text and associated icons. Do not click the warning or condition expression icons). Use the following image as a guide:
Note: Alternatively, right-click the <case> title bar and select Edit.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
b) In the Switch Case window in the General tab page, enter UPS in Name. Note: The value in the Name field becomes a useful visual indicator in the <case> branch title after you complete this step. To create the Expression, click the XPath Expression Builder icon ( ) to construct a conditional expression comparing if the inputVariable > payload > FulfillmentRequest > shipMethod element is equal to the lower case string literal 'two_day'. For example: bpws:getVariableData('inputVariable','payload', '/ns1:FulFillmentRequest/ns5:shipMethod') = 'two_day'
Note: Only if you require help to build the expression, use the following instructions: i) In the Switch Case window, click the XPath Expression Builder icon ( the Expression field. ) for
ii) In the Expression Builder window, in the Variables section expand the inputVariable > FulfillmentRequest tree, select shipMethod and click Insert into Expression iii) In the Expression field append the text ='two_day' (including the single straight quotes) and click OK. 16) Configure second (middle) <case> branch name and condition expression for the USPS service by performing the following steps: a) On the middle <case> branch, double-click the text <case> shown in the title.
Click OK after both fields are completed. Use the following image as a guide:
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
b) In the Switch Case window in the General tab page, enter USPS in Name, and create and Expression, by clicking the XPath Expression Builder icon ( ), that compares if the inputVariable > payload > FulfillmentRequest > shipMethod element is equal to the lower case string literal 'five_day'. For example: bpws:getVariableData('inputVariable','payload', '/ns1:FulFillmentRequest/ns5:shipMethod') = 'five_day' Click OK after both fields are completed. Use the following image as a guide:
17) Configure third right-most <case> branch name and condition expression for the FedEx service by performing the following steps: a) On the middle <case> branch, double-click the text <case> shown in the title. b) In the Switch Case window in the General tab page, enter FedEx in Name, and create and Expression, by clicking the XPath Expression Builder icon ( ), that compares if the inputVariable > payload > FulfillmentRequest > shipMethod element is equal to the lower case string literal 'next_day', or if the shipMethod is equal to 'international'. For example: bpws:getVariableData('inputVariable','payload', '/ns1:FulFillmentRequest/ns5:shipMethod') = 'next_day' or bpws:getVariableData('inputVariable','payload', '/ns1:FulFillmentRequest/ns5:shipMethod') = 'international' Click OK after both fields are completed. Use the following image as a guide:
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
18) Save the changes to your Fulfillment BPEL Process, after verifying that your Switch_shiporder activity appears as shown in the following image:
Note: The names UPS, USPS, and FedEx (as specified in each of the Switch Case settings) now appear as visual annotations in the title for each <case> branch. In this section, you create a variable called shippingRequest whose type is the ShippingRequest element in the projects fulfillment.xsd file.
You create an Assign activity called Assign_shiporder, inside Scope_shiporder before the Switch_shiporder activity, to initialize the variable elements. This variable is used in transform activities to copy the elements to the message structures sent to the JMS service selected by one of the Switch <case> branches.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
19) With the Scope_shiporder activity expanded, click the Variables icon, and in the Create Variables window add a new variable called shippingRequest whose type is the ShippingRequest element in the projects fulfillment.xsd file. Use the following image as a guide:
Note: Only if you require help to create the variable, perform the following steps: a) On the expanded Scope_shiporder, click the Variables icon ( b) In the Variables window, click the Create icon ( i) In the Name field enter: shippingRequest ii) In the Type section, select the Element option. Click the Browse icon next to the Element field, and in the Type Chooser locate and expand Project Schema Files > fulfillment.xsd and select the ShippingRequest element, click OK. iii) Click OK. d) In the Variables window, click OK to close the window. ). c) In the Create Variable window, perform these steps: ).
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
20) In the Fulfillment.bpel Design window, drag an Assign activity into the Scope_shiporder scope before the Switch_shiporder activity. Rename the Assign activity to Assign_shiporder. Use the following image as a guide:
21) Configure the Assign_shiporder, with three copy operations to initialize the contents of the shippingAddress variable (in the Scope_shiporder). Use the following steps (and their associated screenshots as a guide): a) Create a copy operation that copies the orderId element in the inputVariable to the orderId element in the shippingRequest variable:
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
b) Create a copy operation that copies the customerId element of the inputVariable, to the custName element in the shippingRequest variable:
c) Create a copy operation that copies the following XML Fragment into the shippingAddress element of the shippingRequest variable: <ns0:shippingAddress xmlns:ns0="http://www.example.org/ns/fulfillment"> <ns0:street></ns0:street> <ns0:city></ns0:city> <ns0:state></ns0:state> <ns0:zip></ns0:zip> <ns0:country></ns0:country> </ns0:shippingAddress>
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Note: At this stage, since service and associated activities for obtaining the customer address data have not been created, you initialize the XML address elements to the empty elements shown. To save time, open the file D:\labs\files\xml\shipAddress.xml and copy the contents into the XML Fragment area of the copy operation. Observe that the Type in the From section is set to XML Fragment.
Note: When copying an XML fragment the XML Namespace prefix and its associated path are required to preserve the BPEL process source XML structure. 22) Save the changes to your BPEL Process. In this section, you create an Invoke activity to invoke the UPSJmsService and Assign with multiple copy operations preparing the JMS service request message. In the same Assign activity create copy operations to set 'UPS' as the carrier and 'completed' as the status in the outputVariable. 23) Inside the <case UPS> branch, create the sequence of case-sensitively named activities listed in the following table: Activity Type a. Assign b. Invoke Activity Name Assign_toUPS Invoke_UPS
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Use the following image as a guide:
24) Configure the Invoke_UPS activity to execute the Produce_Message operation of the UPSJmsService, and use the Automatically Create Input Variable icon to create a local variable, by performing the following steps: a) Drag a line from the Invoke_UPS activity to the UPSJmsService b) In the Edit Invoke Activity window, click the Automatically Create Input Variable icon, and in the Create Variable window ensure the Local Variable option is selected. Click OK.
25) Configure the Assign_toUPS activity with the following three copy operations:
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
a) Copy the ShippingRequest element from the shippingRequest variable into the ShippingRequest element of the Invoke_UPS_Produce_Message_InputVariable. Note: Both variables are nested in the Scope called Scope_shiporder.
b) Append the literal string ' (UPS)' including the leading space to the custName element in the Invoke_UPS_Produce_Message_InputVariable. Note: Appending the carrier text to the customer name is included here so that you can see the carrier used in the shipping message received by the JMS message consumer application that you use in the testing section of this practice. In this case use the following steps to create an Append Operation: i) In the Assign window, click the Create icon ( Operation. ) and select Append
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
ii) In the Create Append Operation window, in the From section use Expression for the Type and enter ' (UPS)' in the Expression field. In the To section use Variable as the Type and select the custName child element in the Invoke_UPS_Produce_Message_InputVariable as the target.
c) Copy the literal string expression '(UPS)' into the carrier element in the process outputVariable.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
d) Copy the literal string expression completed into the shipStatus element in the process outputVariable.
26) Save the changes to your BPEL Process. In this section, you create an Invoke activity to invoke the USPSJmsService and Assign with multiple copy operations preparing the JMS service request message. In the same Assign activity create copy operations to set 'USPS' as the carrier and 'completed' as the status in the outputVariable. 27) Inside the <case USPS> branch, create the sequence of case-sensitively named activities listed in the following table: Activity Type a. Assign b. Invoke Activity Name Assign_toUSPS Invoke_USPS
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Use the following image as a guide:
28) Configure the Invoke_UPS activity to execute the Produce_Message operation of the USPSJmsService, Use the Automatically Create Input Variable icon to create a local variable, by performing the following steps: a) Drag a line from the Invoke_USPS activity to the USPSJmsService b) In the Edit Invoke Activity window, click the Automatically Create Input Variable icon, and in the Create Variable window ensure the Local Variable option is selected. Click OK.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
29) Configure the Assign_toUSPS activity with the following three copy operations and one append operation: a) Copy the ShippingRequest element from the shippingRequest variable into the ShippingRequest element of the Invoke_USPS_Produce_Message_InputVariable. Note: Both variables are nested in the Scope called Scope_shiporder. b) Append the literal string ' (USPS)' including the leading space to the custName element in the Invoke_USPS_Produce_Message_InputVariable. Use the following steps: i) In the Assign window, click the Create icon ( Operation. ) and select Append
ii) In the Create Append Operation window, in the From section use Expression for the Type and enter ' (USPS)' in the Expression field. In the To section use Variable as the Type and select the custName child element in the Invoke_USPS_Produce_Message_InputVariable as the target. c) Copy the literal string expression 'USPS' into the carrier element in the process outputVariable. d) Copy the literal string expression 'completed' into the shipStatus element in the process outputVariable. 30) Save the changes to your BPEL Process. In this section, you create an Invoke activity to invoke the FedExJmsService and Assign with multiple copy operations to prepare the JMS service request. In the same Assign activity create copy operations to set 'FedEx' as the carrier and 'completed' as the status in the outputVariable. 31) Inside the <case FedEX> branch, create the sequence of case-sensitively named activities listed in the following table: Activity Type a. Assign b. Invoke Activity Name Assign_toFedEx Invoke_FedEx
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
Use the following image as a guide:
32) Configure the Invoke_FedEx activity to execute the Produce_Message operation of the FedExJmsService, and use the Automatically Create Input Variable icon to create a local variable, by performing the following steps: a) Drag a line from the Invoke_FedEx activity to the FedExJmsService b) In the Edit Invoke Activity window, click the Automatically Create Input Variable icon, and in the Create Variable window ensure the Local Variable option is selected. Click OK.
Practice 8-4: Invoke JMS Adapters in the Fulfillment BPEL Process (continued)
33) Configure the Assign_toFedEx activity with the following three copy operations and one append operation: a) Copy the ShippingRequest element from the shippingRequest variable into the ShippingRequest element of the Invoke_FedEx_Produce_Message_InputVariable. Note: Both variables are nested in the Scope called Scope_shiporder. b) Append the literal string ' (FedEx)' including the leading space to the custName element in the Invoke_FedEx_Produce_Message_InputVariable. Use the following steps:
ii) In the Create Append Operation window, in the From section use Expression for the Type and enter ' (FedEx)' in the Expression field. In the To section use Variable as the Type and select the custName child element in the Invoke_FedEx_Produce_Message_InputVariable as the target. c) Copy the literal string expression 'FedEx' into the carrier element in the process outputVariable. d) Copy the literal string expression 'completed' into the shipStatus element in the process outputVariable. 34) In the Fulfillment.bpel Design window, verify that your Scope_shiporder has the BPEL Process flow represented in the following image:
35) Save the changes to your BPEL Process and the POProcessing project.
In this practice, you deploy the modified POProcessing composite application and initiate at least three tests instances with different input data. The three test cases include: Sending an order with a valid credit card Sending an order with an invalid credit card Sending an order with a different ship method to the first test Note: While only three tests are done to cover the two conditions for credit cards and at least on alternative for the ship choice, if there was time one could perform an additional two more test to cover the remaining variations of ship methods available. All test cases are initiated through the Oracle Enterprise Manager Web interface.
1) Using JDeveloper, deploy the POProcessing project to the soaserver connection. When the SOA Deployment Configuration Dialog window is displayed select the Overwrite any existing composites with the same revision ID. Option. Note: If the Authorization Request window is displayed, enter the username weblogic and password welcome1. Ensure the composite application is successfully deployed. 2) In a Web browser window, enter the Oracle Enterprise Manager URL http://localhost:7001/em. If required login with Username: weblogic with Password: welcome1. 3) On the Oracle Enterprise Manager home page, locate and click the deployed POProcessing [1.0] composite application link (located under the SOA tree in the Farm navigation pane). 4) On the POProcessing [1.0] page, click Test.
Test 1: Order with a Valid Credit Card and two_day Ship Method
For this test you use the D:\labs\files\xml_in\po-small-ipod.xml file as input. 5) To run the first test, perform these steps: a) In JDeveloper, select File > Open and select the D:\labs\files\xml_in\po-small-ipod.xml file. First copy all the text in the file into the clipboard, and then close the po-small-ipod.xml window. b) On the POProcessing [1.0] page in the Web browser, in the Request tab Input Arguments section, select the XML View, and paste the clipboard contents into the text area. Click Test Web Service. c) On the Response tab, click the Launch Message Flow Trace link. 6) On the Flow Trace page, under the Trace section examine the Trace Flow. Answer the following questions:
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
a) Was the order processed by the Fulfillment BPEL process? Explain how you verified your answer. b) Which JMS Adapter service received the shipping request, and why was the specific JMS Adapter used? c) In the Audit Trail or the Flow tabbed page for the ApproveCCOrder, which activity receives the response from the ValidateCCService? What is the response messaged child element name that contains the validation information, and what validation value was returned?
Step Answers for Step 6 a. Yes, the order was processed by the Fulfillment BPEL Process. In the Trace tree on the Flow Trace the Fulfillment BPEL component appears below the ApproveCCOrder entry with the state Completed. The Trace tree resembles the following image:
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
Step Answers for Step 6 b. The UPSJmsService received the shipping request. This can be seen by the appearance of UPSJmsService below the Fulfillment entry in the Flow Trace tree. Click the Fulfillment link the Trace tree and click the Flow tab and you can see the names of the Assign_toUPS and related activities in the Switch that confirm the flow of the shipping request. For example:
Note: You can also determine this information from the Audit Trail. Remember the UPSJmsService is selected because the order shipMethod value is two_day, which is tested in the <case UPS> branch of the Switch activity in the Fulfillment BPEL Process.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
Step Answers for Step 6 c. The Invoke_validatecc activity receives the response. If you expand the <payload> under the Invoke_validatecc activity in the Audit Trail you can see the request and reply messages.
The child element containing the validation information is the <inp1:status> element, and the value returned is the string value VALID. 7) Close the Web browser window containing the Flow Trace, Audit Trail or Flow tabbed page.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
a) In the Application Navigator, click the application name and select Open Application.
b) In the Open window, browse to the D:\labs\files folder, select files.jws and click Open.
a) With the files application selected in the Application Navigator select File > Open. b) In the Open dialog box, browse to the D:\labs\files\JmsSendReceive folder, select the JmsSendReceive.jpr file and click Open. Note: If the Open Warning dialog box is displayed, at the Do you want to migrate these files? prompt click Yes. In the Migration Status dialog box, click OK. 10) To run the Receive.java application and receive the JMS message, perform the following steps: a) In the JDeveloper Application Navigator, right-click the JmsSendReceive project folder and select Run. In the JDeveloper Message Log window area a new window titled Running:JmsSendReceive.jpr Log is opened to display the application output (the JMS messages consumed) and receive application input (the letter q and Enter to terminate the application). Note: The JmsSendReceive project properties are set to ensure the Receive.java application is executed by default, and obtains JMS messages from the jms/demoFulfillmentQueue JMS destination.
9) In the JDeveloper window, open the JmsSendReceive project by performing the following steps:
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
b) In the Running:JmsSendReceive.jpr Log window, view the JMS message and confirm that the text (UPS) has been appended to the customer ID in the <custName> element. Use the following image as a guide:
c) In the Running:JmsSendReceive.jpr Log window, to terminate the Receive.java application, at the Input prompt press q and then Enter. d) Close the Running:JmsSendReceive.jpr window. To simplify management and handling of JMS message delivery and consumption during the rest of the practices, you deploy the supplied JMSConsumerDemo project, which is a composite application that: Reads the JMS messages produced by JMS Adapters in the POProcessing composite application. Writes the shipping request JMS message to a file called shiporder_#.xml, where # represents a number that is incremented for each message file created. There is one message file per message and the files are stored in the D:\temp folder. The following image shows the component assembly model for the JMSConsumerDemo composite application:
To perform this task, perform the following steps: 11) In the JDeveloper window, with the files application selected, select File > Open. 12) In the Open window, navigate to the D:\labs\files\JMSConsumerDemo folder, select the JMSConsumerDemo.jpr file and click Open. Note: If an Open Warning window is displayed, at the Do you want to migrate these files? prompt click Yes. In the Migration Status window, click OK.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
13) In the JDeveloper Application Navigator, to deploy the JMSConsumerDemo application right-click the JMSConsumerDemo folder and select Deploy > JMSConsumerDemo > to soaserver. Note: In the SOA Deployment Configuration Dialog, click OK. If the Authorization Request window is displayed, enter the username weblogic and password welcome1. Note: From this point onwards, all subsequent tests of the POProcessing composite application, where the order is sent to a JMS Adapter by the Fulfillment process, a shiporder_#.xml file should be created in the D:\temp folder. 14) In the JDeveloper window, select File > Save All to save changes to the files application.
d) Click Test Web Service. 16) On the Response tab, click the Launch Message Flow Trace link to display the Flow Trace for the test instance and answer the following questions: a) Was the Fulfillment BPEL Process executed? Explain your answer.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
b) What was the status response text received by the Invoke_validatecc activity? c) What is the orders status value returned in the callbackClient activity for the ApproveCCOrder BPEL process? d) Look in the D:\temp folder. Was any shiporder_#.xml file created? Explain what you discovered.
Step Answers for Step 16 a. No the Fulfillment BPEL process was not executed, as observed in the following Flow Trace:
The Fulfillment was not invoked by the ApproveCCOrder BPEL process because the credit card was not valid and Switch activity that checks the ValidateCCService response executed the <otherwise> branch, as seen in the Flow tabbed page for the ApproveCCOrder BPEL component link:
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
Step Answers for Step 16 b. The status returned is the string INVALID. This can be seen in the Audit Trail by expanding the <payload> under Invoke_validatecc (or the Flow tabbed page, by clicking the Invoke_validatecc activity):
c.
The status value returned by the callbackClient activity is invalid credit card as seen in the expanded <payload> of the callbackClient activity in the Audit Trail tabbed page for the ApproveCCOrder activity.
d.
No, a shiporder_#.xml file was not created in the D:\temp folder. The reason why a file was not created is because the Fulfillment process was not executed for the invalid credit card use-case, and a shipping request messages was not sent to any of the JMS adapter services. Therefore, the JMSConsumerDemo application did not execute to create the shipping order XML file.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
Test 3: Valid Credit Card with five_day Ship Method
For this test you reuse the D:\labs\files\po-small-ipod.xml file as input and alter the ship method value to the value five_day before you click Test Web Service. This will check if the order is sent to a different JMS Adapter service from the first test. 17) To run the third and last test, perform these steps: a) In the JDeveloper Application Navigator, expand the files > xml_in project folders and double-click the po-small-ipod.xml file. Copy all the text in the file into the clipboard, and paste the text into the Request tab Input Arguments section, select the XML View, of the on the POProcessing [1.0] Web browser page. b) Edit the XML elements in the data in the XML View area such that: The <ns0:shipChoice> element contains the value five_day.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
18) On the Response tab, click the Launch Message Flow Trace link to display the following Flow Trace page for the test instance and answer the following questions:
a) To which JMS Adapter service was the order shipping request sent? b) Why is the JMSConsumer_ep entry shown below the Fulfillment BPEL Component entry in the Flow Trace? c) Why are the RouteOrder and the associated FulfillmentFileService components present in the Flow Trace? d) Was a shiporder_#.xml file created in the D:\temp folder? Step Answers for step 18 a. The order shipping request was sent to the USPSJmsService, as seen in the Flow Trace tree just below the Fulfillment BPEL Component entry. b. The JMSConsumer_ep entry represents the entry point for the JMSConsumerDemo composite application. This indicates that the JMSConsumerDemo composite application was executed when the shipping request was set to the USPSJmsService. c. The RouteOrder and the associated FulfillmentFileService components are present because they are the instances that processed the shipping request message received by the JMSConsumerDemo composite application. d. Yes. The shiporder_1.xml file was created in the D:\temp folder, and it contains the shipping request XML data sent the USPSJmsService. 19) In the JDeveloper Application Navigator, select the POApplication application name to show the POApplication projects in the navigator tree. Note: You may close the po-small-ipod.xml window.
Practice 8-5: Deploy and Test the POProcessing Composite Application (continued)
Note: Remember, since the JMSConsumerDemo composite application is deployed: all shipping requests sent to any of the JMS Adapter services by the Fulfillment BPEL Process component are written to the D:\temp folder by the JMSConsumerDemo composite application, whose instances appears in the respective Flow Trace trees for the POProcessing composite application.
The ADF-BC services for the Internal Store and Online Store services are supplied, and some initial implementations for the Internal Store and Online are also provided. You are required to perform the following tasks: Deploy the supplied ADF application projects as Web services that query their internal and online stock tables for the quantity of products ordered, and can also update the stock counts if the products are to be acquired for each order. These services are required as external references for the respective composite applications. Modify the supplied InternalStore composite application, which contains a single BPEL process. The BPEL process presently processes one product per order. You must modify the process with a While activity to handle multiple products per order, and implement the activities to invoke acquireStock operation which is
implemented by replacing the Receive activity with Pick activity and associated process flow alterations. Modify the supplied OnlineStore composite application to use a FlowN activity to process more than one product per order. Deploy and test the InternalStore and ExternalStore applications
Note: Part 2 depends on the completion of part 1 tasks. If you do not have enough time, then consider deploying the solution projects from the POApplication.jws workspace in the D:\labs\soln\lesson09\POApplication folder for part 1 services and composite applications. The changes you make to the POProcessing composite include: Modifying the Fulfillment BPEL Process to invoke the InternalStore and OnlineStore in parallel, giving priority to the InternalStore if both can fulfill the order. If both stores are unable to supply stock for the order, the order is modified with a waiting status until an event occurs to replenish stock in the stores. Testing the modified POProcessing application.
In this practice, you open a supplied application workspace called ADFBCApplication that contains four services that are to be used in this course. In this practice you deploy the InternalStoreSDO and OnlineStoreSDO projects to the soaserver connection. Note: To deploy ADF applications you use the JDeveloper Application Menu in the Application Navigator. For example:
To complete the deployment tasks, perform the following steps: 1) On the JDeveloper Application Navigator, open the ADFBCApplication workspace file, from the D:\labs\files\ADFBCApplication folder. Use the following steps: a) On the JDeveloper Application Navigator, click the pull-down menu containing the POApplication (or files) application name, and select Open Application.
The two ADF-BC services deployed (InternalStoreService and OnlineStoreService) are required for Practice 9-2 through Practice 9-4.
2) Deploy the InternalStoreSDO project, by performing the following steps: a) In the Application Navigator, click the Application Menu and select Deploy > InternalStoreSDO_InternalStoreSDOProfile > to > soaserver
b) In the Select Deployment Targets window, select soa_server1 and click OK.
3) Deploy the OnlineStoreSDO project, by performing the following steps: a) In the Application Navigator, click the Application Menu and select Deploy > OnlineStoreSDO_OnlineStoreSDOProfile > to soaserver b) In the Select Deployment Targets window, select soa_server1 and click OK. c) In the Deployment Log window, monitor and verify that deployment is successful. 4) In the JDeveloper window, select File > Save All to save changes to the application workspace due to deployment steps. 5) Confirm that InternalStoreService and OnlineStoreService exist and are working by using the WSIL connection in the Resource Palette. Use the following steps:
c) In the Deployment Log window, monitor and verify that deployment is successful.
a) On the Resource Palette, expand the WSIL > WSILConnection1 entry, and verify that the InternalStoreSDO_InternalStoreSDOProfile and OnlineStoreSDO_OnlineStoreSDOProfile entries are present. Note: You may have to right-click the WSILConnection1 entry and select Refresh to ensure the deployed applications become visible.
b) Expand the InternalStoreSDO_InternalStoreSDOProfile and OnlineStoreSDO_OnlineStoreSDOProfile entries, and verify that the service entry points InternalStoreService and OnlineStoreService are present, respectively.
6) Test the InternalStoreService with the Test Web Service tool in JDeveloper. Use the following steps: a) On the Resource Palette, right-click the InternalStoreService entry, and click Test Web Service.
Note: JDeveloper displays the following message while sending the message and waiting for the response.
c) In the HTTP Analyzer: # window (where # is a message request number) confirm that the response (in the right window pane) displays the ProdId SKU101 and Quantity value 5. Use the following image as a guide:
7) Test the OnlineStoreService with the Test Web Service tool in JDeveloper. Use the following steps: a) On the Resource Palette, right-click the OnlineStoreService entry, and click Test Web Service.
Operations pull-down menu, in the prodId: string field (in the left window pane) enter: SKU101, and click Send Request.
c) In the HTTP Analyzer: # window (where # is a message request number) confirm that the response (in the right window pane) displays the ProdId SKU101 and Quantity value 6. Use the following image as a guide:
d) Close the HTTP Analyzer: # window. Note: The ADF-BC application services deployed are synchronous Web services, and they can also be used as Service Data Object (SDO) implementations.
To complete this task, perform the following steps: In this section you copy the InternalStore composite application project into your POApplication workspace folder, and open the project in the POApplication. 1) Open a Windows Explorer window, and copy the D:\labs\files\InternalStore folder to the D:\labs\mywork\POApplication folder. 2) In the JDeveloper window, open the InternalStore project in the POApplication workspace by using the following steps: a) In the Application Navigator, click the application names on the pull-down menu and select POApplication.
b) In the Application Navigator, click the Application Menu and select Open Project. c) In the Open Project window, navigate to the D:\labs\mywork\POApplication\InternalStore folder, select the InternalStore.jpr file and click Open. Note: In the Open Warning window with the Do you want to migrate these files? prompt, click Yes. In the Migration Status window click OK.
In this practice, you open the InternalStore composite application project, which is located in the D:\labs\files folder. You modify the ManageInventory BPEL Process by: Replacing the Receive activity with a Pick and two onMessage branches, each one to handle one of two operations checkStock and acquireStock defined in the component WSDL. In this case, you set a variable to indicate which operation was requested so that the process flow can manage the request appropriately. Adding a While loop and associated iteration control activities to process multiple product elements and check if stock exists. Activities that obtain the amount of available stock are also needed for the acquireStock operation so that you can decrement the amount of stock available by the amount ordered for the operation that updates the information in the database table. Implementing Switch statements to execute different actions for the different operations and ensure appropriate responses are returned.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Examine the InternalStore Composite Application
3) Expand the InternalStore project and open the composite.xml file. Using the image as a guide answer the questions that follow:
a) Is the checkStock operation a synchronous or an asynchronous interaction? b) Which InternalStoreService operation is used to determine the available stock level for a specific product? c) Which InternalStoreService operations can be used to update stock quantity values in the underlying table? Note: The SOADEMO schema in the Oracle Database 10g XE instance contains a table called INTERNAL_STORE that maintains the product quantity values. You can use the SQL Command Line tool (in Start > Programs > Oracle Database 10g Expression Edition menu to start SQL*Plus), or the SQL Worksheet in JDeveloper to query the database table. Step Answers for step 3 a. It is an asynchronous operation. If you opened the ManageInventory.wsdl file you can see that all the operations are defined with a single message element. The checkStock and acquireStock operations represent the requests. The checkStockResponse and acquireStockResponse operations are for the associated callback responses. b. The getInternalStoreView1 operation is used to obtain the product and quantity available. Note: This operation executes an SQL SELECT statement for a given product ID. c. The updateInternalStoreView1 and mergeInternalStoreView1 operations can both be used to modify the quantity of a given product. Note: In the practice you use the updateInternalStoreView1 operation to implement the functionality for the acquireStock operation. The operation updateInternalStoreView1executes an SQL UPDATE statement. The mergeInternalStoreView1 executes an INSERT statement (if a row with the product ID does not exist) or an UPDATE statement (if a row with the product ID exists).
Oracle SOA Suite 11g: Build Composite Applications 239
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Edit the ManageInventory BPEL Process
4) In the composite.xml window, to edit the BPEL process double-click the ManageInventory BPEL Process component icon. 5) In the ManageInventory.bpel window, before you modify the BPEL process, examine the existing process flow and answer the questions that follow (so that you understand what you are about to change):
a) What operation does the Invoke_checkinstore perform? b) What information is copied by the Assign_prodid as the request message for the Invoke_checkinstore activity? c) What is the result of the copy operation in the Assign_prodinstock activity? d) What is the purpose of the Assign_initialize activity?
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Now examining the process flow at the end of the BPEL process which contains a Switch activity as shown in the following image answer the additional questions:
e) What does the <case inStock> branch condition test, and what are the actions for each of the condition outcomes? Step Answers for step 5 a. The Invoke_checkinstore invokes the getInternalStoreView1 operation. Hint: Double-click the Invoke activity to view the settings. Note: The operation accepts a product ID as the input message and returns the product ID and quantity available from the database (INTERNAL_STORE table). b. The Assign_prodid copies the prodId element from the first product element of the input structure to the request message used by the invocation of the InternalStoreService. Note: In the Assign activity copy operation the From XPath expression is: /ns1:StoreRequest/ns1:product[1]/ns1:prodId In this XPath expression, the [1] syntax represents the index for the first product element in a multi-element structure. c. The result of the copy operation in the Assign_prodinstock is to store a Boolean result of true or false in the inStock variable. The result depends on the value of the conditional expression stored in the From section of the copy operation. The condition stores a true value in the inStock variable if the quantity of stock returned from the invoke operation is more than or equal to the quantity ordered, otherwise a false value is stored in the inStock variable. d. The purpose of the Assign_initialize activity is to initialize the inStock variable to the value true, on the assumption that products are in stock unless the flow determines it is not. This assign activity is more meaningful when you implement the flow logic to process multiple product elements.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Step Answers for step 5 e. The <case inStock> branch condition tests if the inStock variable is true. When the condition is true, the Assign_instock activity copies the in-stock string as the response message; otherwise the Assign_outofstock activity copies the outof-stock string as the response message. In this section you restructure the BPEL process flow to include a While activity to loop through the set of products received for processing and set the While activity termination condition. This requires modifying the Assign_initialize activity to modify the loop counter, and moving activities into the loop, decrementing a loop counter. Note: The While loop is terminated either when all products are processed or the first product that is out of stock is encountered. You also have to modify the XPath expression in the Assign_prodid and Assign_prodinstock copy operations to dynamically access the nth element in the XML array structure. 6) In the ManageInventory.bpel window, restructure the BPEL flow according to the following image:
To create the flow changes represented in the image perform the following steps:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
a) Add a While activity between the Assign_initialize and the Assign_prodid activities. b) Expand the While activity and add a Sequence activity into the body of the While activity. c) Drag the Assign_prodid, Invoke_checkinstore, and Assign_prodinstock activities (in the order stated) into the body of the Sequence_1 activity nested in the While activity. d) After verifying that your process flow resembles the image provided above, save your structural changes to the BPEL process.
If you require help to perform this task, use the following instructions to create the variable: a) On the main process scope, click the Variables icon.
b) In the Variables window, click the Create icon. c) In the Create Variable window, perform the following steps:
7) Create a process variable called n based on the Simple Type option set to xsd:int. This variable is used to control the number of loop iterations and index the product element in the input XML structure. Use the following image as a guide:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
i) Enter n for the Name ii) Select the Simple Type option. iii) Click the Browse icon next to the Simple type option to open the Type Chooser window. iv) In the Type Chooser window, select the int entry and click OK. d) In the Create Variable window, verify your settings match the supplied image above and click OK to create the variable. e) Save the changes to your BPEL process. 8) Modify the Assign_initialize with another copy operation to set the variable n to the number of product elements in the inputVariable. Hint: Use the count Mathematical Function in the XPath Expression Builder. Use the following image as a guide:
If you require help to perform this task, use the following steps: a) Double-click the Assign_initialize activity. b) On the Assign > Copy Operation tabbed page, click the Create icon > Copy Operation.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
c) In the Create Copy Operation window, in the From section set Type as Expression and construct the following Expression:
count(bpws:getVariableData('inputVariable', 'payload','/ns1:StoreRequest/ns1:product')) In the To section, set Type as Variable, select the variable n, and click OK. d) On the Assign page, click OK. 9) Configure the While activity conditional expression so that the loop continues while the value in the variable n is greater than zero and while the inStock variable is still the value true (using the true() Logical Function). For example: bpws:getVariableData('n') > 0 and bpws:getVariableData('inStock') = true() Note: Remember the Assign_initialize has already preset inStock to the value true() to ensure that you enter the while loop. Use the following image as a guide:
If you require help create the While conditional expression, perform the following steps: a) Double-click the While icon. b) On the While > General tabbed page, click the XPath Expression Builder icon to construct the expression. c) In the Expression Builder window, perform the following actions to create the expression: i) Select the BPEL Variable n and click Insert Into Expression. ii) Enter the text > 0 and (excluding the quotes). iii) Place the cursor at the end of the text, select the inStock BPEL variable and click Insert Into Expression.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
iv) At the end of the expression append the text = true() (excluding the double quotes). v) Click OK. d) In the While window, click OK to save the conditional expression. e) Save the changes to your BPEL process. 10) Modify the copy operation in the Assign_prodid activity so that you replace the absolute index [1], in the XPath expression, with the string [position()=$n]. Note: The dollar ($) character preceding the character n is required. Use the following screenshot as a guide:
Your XPath expression should resemble the following: /ns1:StoreRequest/ns1:product[position()=$n]/ns1:prodId If you require help to change the From XPath Expression, perform the following steps: a) Double-click the Assign_prodid activity. b) In the Assign > Copy Operation window, double-click the existing copy operation row to open the Edit Copy Operation window. c) In the Edit Copy Operation window, in the XPath field under the From section replace the digit 1 inside the square brackets with position()=$n. For example:
d) In the Edit Copy Operation window, click OK to accept the change. e) In the Assign window, click OK.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
f) Save the changes to your BPEL process. 11) Modify the copy operation in the Assign_prodinstock activity so that the nth product ID quantity is used in the conditional expression. Use the following image as a guide:
Note: The simplest way to change the From Expression is to select the digit 1 between the square brackets and replace it with the highlighted text position()=$n. 12) You require one more Assign activity in the While sequence to decrement the value of the variable n by a value of one at the end of the loop. Use the following image as a guide:
a) Drag an Assign activity as last activity in the Sequence inside the While activity. b) Rename the Assign activity to Assign_next_n.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
13) Configure the Assign_next_n activity to decrease the value in the variable n by one, and assign the result back to the variable n. Use the following screenshot as a guide:
Note: The From Expression should resemble the following example: bpws:getVariableData('n') 1 14) Save the changes to your BPEL process and POApplication workspace. In this section, you replace the Receive activity with a Pick activity. You modify the Pick activity by adding another onMessage branch and deleting the onAlarm branch. The rest of the BPEL flow must be modified to execute the appropriate activities for the checkStock operation, and additional activities for the acquireStock operation. Therefore addition Switch activities are required to determine which operation was requested. The onMessage branch sets a variable to indicate the operation requested so that the Switch branches can evaluate an appropriate condition and execute the required activities. 15) In the ManageInventory.bpel Design window, at the start of the BPEL process flow replace the Receive activity with a Pick activity. Use the following steps: a) Delete the receiveInput activity b) Drag a Pick activity to the start of the BPEL process. 16) Edit the Pick_1 activity and change its name to Pick_operation and set the Create Instance option by using the following steps:
Oracle SOA Suite 11g: Build Composite Applications 248
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
a) Double-click the Pick_1 activity to open the Pick settings. b) On the Pick > General settings page, replace the Name with Pick_operation, select the Create Instance option, and click OK.
17) In the ManageInventory.bpel Design window, expand and configure the Pick_operation to have two onMessage branches and delete the onAlarm branch. Hint: Click the Add OnMessage Branch icon ( branch. Use the following image as a guide: ) to create an additional onMessage
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
18) Configure the first onMessage branch to be associated with the manageinventory_client partner link, the checkStock operation, and use the inputVariable. Use the following image as a guide:
If you require help to perform this task, perform the following steps: a) Double-click the first (left-most) onMessage branch icon. b) In the OnMessage Branch window, configure the following settings: Partner Link: manageinventory_client (Click the Browse icon to select the partner link) Operation: checkStock Variable: inputVariable (Click the Browse icon to select the variable) Click OK. 19) Configure the second (right-most) onMessage branch to be associated with the manageinventory_client partner link, the acquireStock operation, and use the inputVariable. Use the following image as a guide:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
20) Save the changes to you BPEL process.
22) In the ManageInventory.bpel Diagram window, expand both onMessage branches of the Pick_operation activity and create a named Assign activity in the each branch as defined by the following table: Activity Type and Name a. Assign: Assign_checkstock b. Assign: Assign_acquirestock Location In the left OnMessage Branch In the right OnMessage Branch
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Use the following image as a guide:
23) Configure the Assign_checkstock with a copy operation that stores the string literal check in the operation variable. Use the image as a guide:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
24) Configure the Assign_acquirestock with a copy operation that stores the string literal acquire in the operation variable. Use the image as a guide:
25) Save the changes to your BPEL process. The While loop needs the Assign_prodinstock to be executed when the operation=check, and different activities when operation=acquire. To make this change you add Switch activity, into the While loop, with a conditional expression on the operation variable and configure its <case> and <otherwise> branches with appropriate activities for each operation.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
26) In the ManageInventory.bpel Diagram, drag a Switch activity into the While activity Sequence between the Invoke_checkinstore and Assign_prodinstock activities. Rename the Switch activity to Switch_operation. Use the following image as a guide:
27) Expand the Switch_operation to structure the <case> branch and <otherwise> branch as described by the following steps: a) Drag the Assign_prodinstock activity into the <case> branch. b) In the <otherwise> branch, add the following activities in the sequence listed: i) Drag a new Assign activity renamed to Assign_updstock. ii) Drag a new Invoke activity renamed to Invoke_updstock.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
Use the following image as a guide:
28) Configure the <case> branch name to operation=check and set the conditional expression to ensure that the operation variable is equal to the literal string 'check', as shown in the following image:
Note: The conditional expression should resemble the following text: bpws:getVariableData('operation') = 'check'
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
29) Link the Invoke_updstock with the InternalStoreService, using the drag and drop technique or double-click the activity and set the partner link to InternalStoreService and select updateInternalStoreView1 as the Operation. For the Input and Output use the Automatically Create Input (or Output) Variable icons, respectively to create the required variables as Global Variables. Use the following image as a guide to the Invoke settings:
30) Configure the Assign_updstock with the following two copy operations:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
a) Copy the nth products prodId element to the corresponding element in the Invoke_updstock_updateInternalStoreView1_InputVariable. Use the following image as a guide:
Note: To set the correct XPath expression for the nth product, perform the following steps in the From section: i) Select the Type as Variable. ii) Expand the inputVariable > payload > StoreRequest > product node and select the prodId element. iii) In the XPath Expression field add the text [position()=$n] after the /ns1:product and before the /ns1:prodId in the XPath expression:
/ns1:StoreRequest/ns1:product[position()=$n]/ns1:prodId
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
b) Create an expression that subtracts the inputVariables nth product qtyOrdered element from the quantity in the Invoke_checkinstore_getInternalStoreView1_OutputVariable. Copy the result of this expression to the quantity in the Invoke_updstock_updateInternalStoreView1_InputVariable. Use the following image as a guide:
Note: Verify that the From text resembles the following expression:
bpws:getVariableData('Invoke_checkinstore_getInternalStoreV iew1_OutputVariable','parameters','/ns3:getInternalStoreVie w1Response/ns3:result/ns2:Quantity') bpws:getVariableData('inputVariable','payload','/ns1:StoreR equest/ns1:product[position()=$n]/ns1:qtyOrdered')
Hint: If you wish, you can copy the left-side of the conditional expression in the copy operation in the Assign_prodinstock activity, which resembles the above calculation.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
31) Verify that your While loop contains the following changes to its activity sequence, and save the changes to your BPEL process:
In this section the final change you make to the ManageInventory BPEL Process is to create one more Switch activity to manage the different responses sent to the client using the callback Invoke activities. Again the Switch activity must determine for which operation (check or acquire) you are returning a response and configure its branches accordingly.
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
32) In the ManageInventory BPEL Diagram window, create a new Switch called Switch_response outside the While activity between the While and existing Switch activity at the end of the process. Use the following image as a guide:
33) Expand the Switch_response activity and configure the <case> branch conditional expression to check if the operation variable is equal to the literal string check. Use the following image as a guide:
34) Structure the Switch <case> and <otherwise> branch such that: a) The <case> branch contains: i) The Switch_instock activity (and its branches), which is the Switch activity end of the process. ii) The callback activity. b) The <otherwise> branch contains:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
i) A new Assign activity named Assign_fulfilled. ii) A new Invoke activity called callbackClient_fulfilled. Use the following image as a guide:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
35) Configure the Assign_fulfilled activity with a copy operation that stores the literal string fulfilled in the outputVariable status element. Use the following image as a guide:
36) Configure the callbackClient_fulfilled activity to invoke the manageinventory_client partner link with the acquireStockResponse callback operation and use outputVariable as Input variable. Use the following image as a guide:
Practice 9-2: Modify InternalStore with Pick and While Activities (continued)
37) Close and reopen the ManageInventory.bpel file and verify that the final Switch activity flow sequence resembles the following image:
38) Close the ManageInventory.bpel window and the InternalStore composite.xml file. Save changes to your BPEL process and POApplication workspace.
In this practice, you open and modify the ManageStock BPEL Process implementation in the OnlineStore composite application, and answer some questions to facilitate your understanding of parts of the implementation. The OnlineStore composite assembly model is similar to the InternalStore application as shown in the following image:
Note: The difference in the OnlineStore, as compared to InternalStore assembly mode, is that the external reference is for the OnlineStoreService (another ADF-BC server that you deployed earlier in these practices). The OnlineStoreService queries and manages data in the ONLINE_STORE database table. To complete this task perform the following steps: 1) Open a Windows Explorer window, and copy the D:\labs\files\OnlineStore folder to the D:\labs\mywork\POApplication folder. 2) In the JDeveloper window, open the OnlineStore project in the POApplication workspace by using the following steps: a) In the Application Navigator, with the POApplication selected click the Application Menu and select Open Project. b) In the Open Project dialog box, navigate to the D:\labs\mywork\POApplication\OnlineStore folder, select the OnlineStore.jpr file and click Open. Note: In the Open Warning window with the Do you want to migrate these files? prompt, click Yes. In the Migration Status window click OK. In this section you open and examine the ManageStock BPEL existing implementation and answer questions so that you can modify the code with some awareness of the changes required when you implement the FlowN to process multiple products. Note: If you prefer, to save time you can skip and read the questions at another time. 3) In the Application Navigator, expand the OnlineStore composite project and doubleclick the ManageStock.bpel process to open it in the BPEL Editor. 4) In the ManageStock.bpel Design window, examine the process flow elements and answer the following questions:
a) Does the ManageStock BPEL Process support all the operations (checkStock, checkStockResponse, acquireStock, and acquireStockResponse) defined in ManageStock.wsdl? Explain your answer. b) What does the Assign_prodid activity do? c) What does the Assign_newqty activity do? Explain why? Hint: There are two reasons. By examining the Assign_updstock_data activity in the <case Acquire Stock?> branch of the Switch_acquirestock activity, and the <case Any out of stock?> branch conditional expression you may find a way to explain the logic used.
Answers for step 4 a. Yes. The process contains a Pick activity, with two onMessage branches at the start of the process. One onMessage branch is for the checkStock operation and the other is for the acquireStock operation. In addition, the process provides two callback (invoke) activities at the end of the process. Scroll to end of the process design, and if required expand the Switch_operation activity. One callback is called callbackClient activity, which is for the checkStockResponse operation and the other is called callbackClient_fulfilled, which is for the acquireStockResponse operation. Note: The callback activities are contained in the last Switch activity (called Switch_operation) of the ManageStock BPEL process. You may need to expand the Switch_operation activity to view the callback activities. b. The Assign_prodid activity copies the first prodId element from the XML array in the inputVariable to the request message for the Invoke_checkstore activity. Note: The Assign_prodid copy operation must be modified to dynamically access the product XML array using the [position()=$n] condition added to the XPath expression. c. The Assign_newqty subtracts the quantity of stock ordered (qtyOrdered in the InputVariable) from the amount of stock available in the online store database, and copies the result back into the qtyOrdered in the inputVariable. The reasons why this logic is performed are: 1. It simplifies the Assign_updstock_data copy operation for setting the new quantity value to be used to update the database table for the specified product, that is, it does not need to repeat the subtraction expression already performed. Note: The copy operations on the Assign_newqty and Assign_updstock_data must be modified to dynamically access the product XML array using the [position()=$n] condition added to the XPath expression. 2. It enables the <case Any out of stock?> branch conditional expression to determine if any of the products are out of stock by a simple XPath expression that returns a true value if any qtyOrdered element contains a negative value, that is, not enough stock to satisfy the order.
d) Why is the input and output variables for the Invoke_checkstore and Invoke_updstock defined as local variables in the Scope_stockprocess scope?
6) In the ManageStock.bpel Design window, drag a FlowN activity before the Scope_stockprocess activity. Use the following image as a guide:
7) To edit and configure the FlowN_1 activity settings, double-click FlowN_1 activity icon and perform the following steps:
a) In the Flow settings window, next to the N field, click the XPath Expression Builder icon ( ) to define an expression that initializes the variable n to the count of product elements in the inputVariable. Use the following Expression Builder image as a guide to creating the expression:
b) In the FlowN settings window, click the Browse Variables icon ( ) next to the Index Variable field and select the process variable n, and click OK after setting the Index Variable. Use the following image as a guide:
Note: The Scope_stockprocess activity expands when your drop it into the sequence above. The image shows the scope in a collapsed state for readability. 10) Save the changes to your BPEL process.
12) In the ManageStock.bpel Design window, double-click the Assign_newqty activity and modify the copy operation by replacing the [1] string in, both the From Expression and the To XPath expression, with the [position()=$n] string. Use the following image as a guide:
14) Close ManageStock.bpel and composite.xml windows, and save all changes.
In this practice, you deploy and test if the modified InternalStore and OnlineStore composite applications operate as expected, before you make use of them in the Fulfillment BPEL Process of the POProcessing composite application. To complete these tasks perform the following steps: 1) In the JDeveloper Application Navigator window, ensure that the POApplication and its projects are displayed.
3) To deploy the OnlineStore composite application, right-click the OnlineStore project node and select Deploy > OnlineStore > to soaserver. In the SOA Deployment Configuration Dialog, click OK. Note: Monitor the Deployment Log window to ensure deployment is successful. Note: Now that the composite applications are deployed, if you trust that you have correctly and successfully created the InternalStore and OnlineStore composite applications, to save time you can skip the rest of this practice and start with instructions for the practice titled Add a Flow to the Fulfillment BPEL Process in this lesson. In this section you perform two SQL queries to view the existing stock for three of the products the database tables for the InternalStore and OnlineStore. The database tables queried are called INTERNAL_STORE and ONLINE_STORE, respectively. 4) In the JDeveloper window, execute a query on the INTERNAL_STORE database table to check the available stock for the following three product IDs: SKU101, SKU102, and SKU200. Use the SQL statement in the file called D:\labs\files\int_store_query.sql in the following steps to perform this task: a) On the JDeveloper Application Menu, select the files application name. Note: If the files application is not open, select File > Open, browse for and open the D:\labs\files\files.jws file.
2) To deploy the InternalStore composite application, right-click the InternalStore project node and select Deploy > InternalStore > to > soaserver. In the SOA Deployment Configuration Dialog, click OK. Note: Monitor the Deployment Log window to ensure deployment is successful.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
b) In the Application Navigator, expand the files > Application Sources > sql folder, and right-click int_store_query.sql and select Open. Alternatively, double-click the file name. Note: The SQL file is displayed in a SQL Worksheet window. c) In the int_store_query.sql (SQL Worksheet) window, confirm you have the following SQL statement, and click the Execute Statement icon ( ). Select * from internal_store where prod_id in ('SKU101', 'SKU102', 'SKU200');
Note: Ensure that the cursor is placed in or at the end of the SQL statement. d) In the Select Connection window, select the soademo(POApplication) connection, and click OK.
e) In the int_store_query.sql (SQL Worksheet) window, you can observe the query results displayed in the Results tab below the pane containing the SELECT statement. Use the following image as a guide:
Note: There is a quantity of 5 for each prod_id value displayed. f) Close the int_store_query.sql window.
Oracle SOA Suite 11g: Build Composite Applications 274
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
5) In the JDeveloper window, execute a query to check the available stock in the ONLINE_STORE database table for the same three product IDs: SKU101, SKU102, and SKU200. Use the SQL statement in the file called D:\labs\files\onl_store_query.sql in the following steps to perform this task: a) In the Application Navigator, under the files > Application Sources > sql folder, and right-click onl_store_query.sql and select Open. Alternatively, double-click the file name. b) In the onl_store_query.sql (SQL Worksheet) window, confirm you have the following SQL statement, and click the Execute Statement icon ( ). Use the following image as a guide:
Note: Verify the following SQL statement is executed: Select * from online_store where prod_id in ('SKU101', 'SKU102', 'SKU200'); c) In the Select Connection window, select the soademo(POApplication) connection. d) In the onl_store_query.sql (SQL Worksheet) window, you can observe the query results displayed in the Results tab below the pane containing the SELECT statement. Use the following image as a guide:
Note: There is a quantity of 6,8,2 respectively for the prod_id values displayed. e) Close the onl_store_query.sql window.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
6) In a Web browser, access the Oracle Enterprise Manager page (URL http://localhost:7001/em), and login as the user weblogic with password welcome1.
7) On the Oracle Enterprise Manager SOA home page, expand the SOA folder in the Farm navigator, and click the InternalStore [1.0] link. 8) On the InternalStore [1.0] page, click Test. 9) On the InternalStore [1.0] Test Web Service page, ensure that the Operation selected is checkStock, for example:
10) On the InternalStore [1.0] Test Web Service page, under the Request tab Input Arguments section, select the XML view and replace the XML data with the contents of the file D:\labs\files\xml_in\prod-in-store.xml, and click Test Web Service. Note: You can find this file in the files > Application Sources > xml_in folder in the JDeveloper Application navigator window with the files application selected. a) On the Response tab, click the Launch Message Flow Trace link. b) On the Flow Trace page, click the ManageInventory BPEL component link. Note: You might need to refresh the page until you observe the following results in the Flow Trace:
c) On the Instance of ManageInventory Audit Trail page, scroll down and expand the <payload> for the callbackClient activity at the end of the flow.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
i) What is the response in the status element of the callback? Answer: It should be in-stock, as shown in the following image:
ii) Optionally, if you are interested, expand other flow activity entries to examine the flow execution sequence, and verify that each time the InternalStoreService is invoked with each product Id supplied in the inputVariable. d) Close the Flow Trace Web page, and return to the Test Web Service page. 11) On the InternalStore [1.0] Test Web Service page, click the Request tab again, and modify the qtyOrdered element value in the second product (prodId value SKU102) to the value 10, and Click Test Web Service. For example:
a) On the Response tab, click the Launch Message Flow Trace link.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
b) On the Flow Trace page, observe that the InternalStoreService was invoked twice (not three times) and click the ManageInventory BPEL component link.
i) What is the response in the status element of the callback? Answer: It should be out-of-stock, as shown in the following image:
Note: For a degree of simplicity in the application scenario, the BPEL process reports an out-of-stock status if any one of the ordered products cannot be filled by the amount of stock available. The While loop condition terminates additional processing when the first product is encountered that does not have sufficient quantity in the database to fulfill the order. ii) Optionally, if you are interested, expand other flow activity entries to examine the flow execution sequence, and verify that each time the InternalStoreService is invoked with each product Id supplied in the inputVariable. d) Close the Flow Trace Web page. In this section you perform one test with ordered quantities that are less than the amount available to check that the stock quantities in the database tables are correctly decreased by the ordered amount.
c) On the Instance of ManageInventory Audit Trail page, scroll down and expand the <payload> for the callbackClient activity at the end of the flow.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
12) On the InternalStore [1.0] Test Web Service page, select the acquireStock operation.
a) On the Response tab, click the Launch Message Flow Trace link. Note: In the Flow Trace tree there should be six rows of the InternalStoreService present. b) On the Instance of ManageInventory Audit Trail page, scroll down and expand the <payload> for the callbackClient_fulfilled activity at the end of the flow. c) What is the response in the status element of the callbackClient_fulfilled? Answer: It should be fulfilled, as shown in the following image:
Note: The process logic does not yet support the condition that there is not enough quantity for products being acquired. This is omitted to eliminate a further degree of complexity in the practices. However, the Fulfillment BPEL process flow modified in the lesson 8 practice titled Deploy and Test the POProcessing Composite Application will first check if the products are available and then invoke the acquireStock operation. d) Close the Flow Trace window. 14) In the JDeveloper window, execute the SQL statement to verify that the quantity values for the products ordered from the INTERNAL_STORE database table have been decreased. Use the following steps:
13) On the InternalStore [1.0] Test Web Service page, click the Request tab again and replace all the XML in the XML View with the data from the D:\labs\files\xml_in\prod-in-store.xml file, and click Test Web Service.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
a) In the Application Navigator, in the files application under the files > Application Sources > sql folder, and right-click int_store_query.sql and select Open. Alternatively, double-click the file name. b) In the int_store_query.sql window, click the Execute Statement icon ( ), and select any of the soademo connections. Verify that you obtain the following results in the Results tab:
| Note: The product quantities should be less than 5 for each of the listed products. There should be two SKU101 products available, three SKU102 products, and four SKU200 products. c) Close the int_store_query.sql window.
Under the Request tab in the Input Arguments section, select the XML view and replace the XML data with the contents of the file D:\labs\files\xml_in\prod-in-store.xml, and click Test Web Service. Note: You can find this file in the files > Application Sources > xml_in folder in the JDeveloper Application navigator window with the files application selected. a) On the Response tab, click the Launch Message Flow Trace link.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
b) On the Flow Trace page, click the ManageStock BPEL component link.
i) What is the response in the status element of the callback? Answer: It should be in-stock, as shown in the following image:
ii) Optionally, if you are interested, expand and examine the flow created by the FlowN activity. Verify that each branch of the FlowN processes a different product Id supplied from the inputVariable. d) Close the Flow Trace Web page.
c) On the Instance of ManageStock Audit Trail page, scroll down and expand the <payload> for the callbackClient activity at the end of the flow.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
18) On the OnlineStore [1.0] Test Web Service page, click the Request tab again, and modify the quantity to a value of 10 for the second product (with product ID SKU102), and click Test Web Service. Use the following image as a guide:
a) On the Response tab, click the Launch Message Flow Trace link. b) On the Flow Trace page, click the ManageStock BPEL component link. Note: The OnlineStoreService reference row appears three times.
c) On the Instance of ManageStock Audit Trail page, scroll down and expand the <payload> for the callbackClient activity at the end of the flow. What is the response in the status element of the callback? Answer: It should be out-of-stock, as shown in the following image:
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
d) Why did three rows with the OnlineStoreService reference appear in the Flow Trace tree? Answer: Because the FlowN logic executes the invoke activity in each of the three branches and the process determines if any product out of stock in a Switch <case Any out of stock?> branch conditional expression. e) Close the Flow Trace Web page.
19) On the OnlineStore [1.0] Test Web Service page, select the acquireStock operation.
20) On the OnlineStore [1.0] Test Web Service page, click the Request tab again and replace all the XML in the XML View with the data from the D:\labs\files\xml_in\prod-in-store.xml file, and click Test Web Service. a) On the Response tab, click the Launch Message Flow Trace link. Note: In the Flow Trace tree six rows of the OnlineStoreService present.
In this section you perform one test with ordered quantities that are less than the amount available to check that the stock quantities in the database tables are correctly decreased by the ordered amount.
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
b) On the Instance of ManageStock Audit Trail page, scroll down and expand the <payload> for the callbackClient_fulfilled activity at the end of the flow. What is the response in the status element of the callbackClient_fulfilled? Answer: It should be fulfilled, as shown in the following image:
c) Close the Flow Trace window. 21) In the JDeveloper window, execute the SQL statement to verify that the quantity values for the products ordered from the ONLINE_STORE database table have been decreased. Use the following steps: a) In the Application Navigator, in the files application under the files > Application Sources > sql folder, and right-click onl_store_query.sql and select Open. Alternatively, double-click the file name. b) In the onl_store_query.sql window, click the Execute Statement icon ( ), and select any of the soademo connections. Verify that you obtain the following results in the Results tab:
Note: The product quantities for the listed products are: three SKU101 products available, six SKU102 products, and one SKU200 product. c) Close the onl_store_query.sql window. After decreasing the stock quantities in the database you now modify the code to reset the stock quantity values in the INTERNAL_STORE and ONLINE_STORE tables. 22) In the JDeveloper window, execute the SQL script to reset the quantity values for the selected set of products in the INTERNAL_STORE and ONLINE_STORE database table. Use the following steps:
Oracle SOA Suite 11g: Build Composite Applications 284
Practice 9-4: Deploy and Test InternalStore and OnlineStore Applications (continued)
a) In the Application Navigator, in the files application under the files > Application Sources > sql folder, and right-click reset_store_data.sql and select Open. Alternatively, double-click the file name. b) In the reset_store_data.sql window, click the Run Script icon ( ), and select any of the soademo connections. Verify that you obtain the following results in the Results tab:
c) Close the onl_store_query.sql window. 23) In the Application Navigator, select POApplication name from the application pulldown menu.
In this practice, you create a Flow activity to perform parallel processing of stock availability checks with the InternalStore and OnlineStore applications. The following image shows part of the implementation of activities in the Scope_checkstock in the Fulfillment BPEL Process of the POProcessing composite application:
Note: The InternalStore and OnlineStore composite applications are asynchronous. For brevity the following activities are not illustrated in diagram within the Switch: The Assign activities that prepare requests for the invocation of the acquireStock operations. The Receive activities for the acquireStockResponse operations To create the parallel flow in the Fulfillment BPEL Process, perform the following steps: 1) In the JDeveloper Application Navigator, under the POApplication in POProcessing project, double-click and open the Fulfillment.bpel file in the BPEL Editor window. In this section you create the partner links for the InternalStore and OnlineStore composite applications. Note: Do not create partner links for the ADF-BC services called InternalStoreService and OnlineStoreService. 2) In the Fulfillment.bpel Design window, drag Partner Link (Web Service/Adapter) component into the Partner Link column on the right side of the window, and configure the partner link using instructions in the following table and associated images as a guide:
c.
d. a)
Fulfillment.bpel Design
b) Note: You may have to select the File System option and then select the Resource Palette again to refresh the list of SOA entries displayed.
c)
d)
c.
d. a)
Fulfillment.bpel Design
b) Note: You may need to select the File System option and select the Resource Palette again to refresh the list of SOA entries displayed.
c)
d)
8) Expand the Flow_checkstock activity. 9) Save the changes to your BPEL Process. In this section, in the left branch of the Flow activity you create an asynchronous invocation pattern using an Invoke with the InternalStore checkStock operation, and a Receive with the checkStockResponse operation. You also create a Transform activity to prepare the data for the Invoke activity. 10) Inside the Sequence_1 activity of the left-branch of the Flow_checkstock activity create the following three activities in the sequence listed: Activity Type a. Transform b. Invoke Activity Name Transform_internalstore Invoke_internalstore
a. b.
11) First, to configure the Invoke_internalstore activity, double-click the Invoke_internalstore activity and associate it with the InternalStore with the checkStock operation. Ensure that you use the Automatically Create Input Variable icon to create a Local Variable. Use the following Create Partner Link image as a guide:
b) In the Transformation_internalstore.xsl window, expand the source column and drag the item element to the product element in the target column. Use the following image as a guide:
c) In the Auto Map Preferences window, accept the default settings and click OK.
e) Save the changes to your project, and close the Transformation_internalstore.xsl window.
13) To configure the settings for the Receive_internalstore activity, double-click the Receive_internalstore activity, set Partner Link to InternalStore, set Operation to checkStockResponse, and click the Automatically Create Variable icon to create Local Variable with the default name provided. Use the following image as a guide:
14) Verify that your Flow_checkstock is configured with activities and partner links shown in the following image:
15) Save the changes to the Fulfillment BPEL Process. In this section, in the right branch of the Flow activity you create an asynchronous invocation pattern using an Invoke with the OnlineStore checkStock operation, and a Receive with the checkStockResponse operation. You also create a Transform activity to prepare the data for the Invoke activity. 16) Inside the Sequence_1 activity of the right-branch of the Flow_checkstock activity create the following three activities in the sequence listed: Step a. b. c. Activity Type Transform Invoke Receive Activity Name Transform_onlinestore Invoke_onlinestore Receive_onlinestore
17) To configure the Invoke_onlinestore activity, double-click the Invoke_onlinestore activity and associate it with the OnlineStore with the checkStock operation. Ensure that you use the Automatically Create Input Variable icon to create a Local Variable. Use the following Create Partner Link image as a guide:
18) To configure the Transform_onlinestore activity, double-click the Transform_onlinestore activity and perform the following steps:
Oracle SOA Suite 11g: Build Composite Applications 297
b) In the Transformation_onlinestore.xsl window, expand the source column and drag the item element to the product element in the target column. c) In the Auto Map Preferences window, accept the default settings and click OK. d) In the Transformation_onlinestore.xsl window, expand the source and target elements and verify your mapper file resembles the following image:
20) Verify that your Flow_checkstock is configured with activities and partner links shown in the following image:
21) Save the changes to the Fulfillment BPEL Process. In this section you configure two <case> branches to check if the responses from each store are in-stock. The left-to-right visual order of the <case> branches are important, where the <case> branch for the InternalStore should appear as the left-most <case> branch (in the source code it appears as the first <case> branch). This ensures that the InternalStore is selected to provide the products for an order if it returns an in-stock response. Next the <case> branch for the in-stock condition is evaluated for the OnlineStore, which is only selected as the supplier of products if the InternalStore returns an out-of-stock response. Finally, the <otherwise> branch is configured for the situation where both the InternalStore and OnlineStore return an out-of-stock response and the order has to be placed in a waiting state until the product quantities in each store are updated.
Configure the Switch to Select the Store that Fulfills the Order
23) Configure the left-most Switch Case settings to check the response in the Receive_internalstore_checkStockResponse_InputVariable by performing the following steps: a) Double-click the <case> title section on the left-most <case> branch.
b) In the Switch Case settings window, set Name to internalstore=instock and build an Expression that compares the status element in the Receive_internalstore_checkStockResponse_InputVariable with the string 'instock'. Use the following image as a guide:
24) Configure the second Switch Case settings to check the response in the Receive_onlinestore_checkStockResponse_InputVariable by performing the following steps: a) Double-click the <case> title section on the middle <case> branch.
25) Save the changes to the Fulfillment BPEL Process. In this section you create and name all the activities that are executed in the two <case> branches and the <otherwise> branch of the Switch_selectstore activity.
b) In the Switch Case settings window, set Name to onlinestore=in-stock and build an Expression that compares the status element in the Receive_onlinestore_checkStockResponse_InputVariable with the string 'instock'. Use the following image as a guide:
For additional instructions, use the following steps: a) To create activities in the <case internalstore=in-stock> branch perform the following steps: i) Drag an Assign activity into the left <case> branch and rename it to Assign_acquireinternal. ii) Drag an Invoke activity into the left <case> branch after the Assign_acquireinternal activity and rename it to Invoke_acquireinternal. iii) Drag a Receive activity into the left <case> branch after the Invoke_acquireinternal activity and rename it to Receive_acquireinternal. b) To create activities in the <case onlinestore=in-stock> branch perform the following steps: i) Drag an Assign activity into the middle <case> branch and rename it to Assign_acquireonline. ii) Drag an Invoke activity into the middle <case> branch after the Assign_acquireonline activity and rename it to Invoke_acquireonline.
c) For the <otherwise> branch, drag an Assign activity into branch and rename the activity to Assign_waiting. 27) Save the changes to the Fulfillment BPEL Process. In this section, you configure the Invoke_acquireinternal to use the acquireStock operation in the InternalStore, assign the items already in a local scope variable to the request message, and configure the Receive_acquireinternal to execute the acquireStockResponse operation of the InternalStore. Note: For simplicity, activities that check the response in messages returned from the acquireStockResponse operation are not included. For now assume that the products are successfully acquired and the order fulfilled. 28) To configure the Invoke_acquireinternal, set the Partner Link to InternalStore, Operation to acquireStock, and for Input automatically create a Local Variable with the default name provided. Use the image as a guide:
29) To configure the Assign_acquireinternal, create two copy operations using the following steps:
a) In the first copy operation, assign the StoreRequest element from the Invoke_internalstore_checkStock_InputVariable to the StoreRequest element in the Invoke_acquireinternal_acquireStock_InputVariable. Note: The Invoke_internalstore_checkStock_InputVariable was already populated by the Transform_internalstore activity.
b) In the second copy operation, assign the literal string 'completed' to the shipStatus in the outputVariable. Use the image as a guide:
31) Save the changes to the Fulfillment BPEL Process. In this section, you configure the Invoke_acquireonline to use the acquireStock operation in the OnlineStore, assign the items already in a local scope variable to the request message, and configure the Receive_acquireonline to execute the acquireStockResponse operation of the OnlineStore. Note: For simplicity, activities that check the response in messaged returned from the acquireStockResponse operation are not included. For now you assume that the products are successfully acquired and the order fulfilled.
33) To configure the Assign_acquireonline, create two copy operations using the following steps:
a) In the first copy operation, assign the StoreRequest element from the Invoke_onlinestore_checkStock_InputVariable to the StoreRequest element in the Invoke_acquireonline_acquireStock_InputVariable. Note: The Invoke_onlinestore_checkStock_InputVariable was already populated by the Transform_onlinestore activity.
b) In the second copy operation, assign the literal string 'completed' to the shipStatus in the outputVariable. Use the image as a guide:
35) Save the changes to the Fulfillment BPEL Process. In this section, you configure the Assign_waiting activity in the <otherwise> branch to update the shipStatus in the outputVariable to indicate the order is not shipped because neither store has items in stock.
36) To configure the Assign_waiting, create a copy operation that stores the literal value 'waiting' in the shipStatus element of the outputVariable. Use the image as a guide:
37) In the Fulfillment BPEL Process Design window verify that the Switch_selectstore activity resembles the following image:
Important Note: In above image of the Switch_selectstore activity flow, ensure that the left-most <case> branch is titled <case internalstore=in-stock>, otherwise the process will not work as documented to acquire stock from the internal store first when both the internal and online store have items in stock. Do this if and only if the <case internalstore=in-stock>, is not the left most <case> branch. Perform the following steps to fix it in the Source code window: a) In the Fulfillment.bpel Design window, expand the Switch_selectstore activity.
c) In the Fulfillment.bpel Design window, at the bottom-left side of the window click the Source tab.
d) In the Fulfillment.bpel Source window, just below the <switch name=="Switch_selectstore"> element, click the collapse icon in the line gutter for the line containing the source code starting with <case condition="bpws:getVariableData('Receive_onlinestore_...
g) In the Fulfillment.bpel Source window, after dragging the internal store <case> branch the Source window automatically expands the code and you can verify that the <case condition="bpws:getVariableData('Receive_internalstore_... line appears immediately after the <switch name="Switch_selectstore"> element:
h) In the Fulfillment.bpel Source window, at the bottom-left side of the window click the Design tab.
f) In the Fulfillment.bpel Source window, select the entire second (bottommost) collapsed <case condition="bpw </sequence></case> line, and drag it before the first <case condition="bpw </sequence></case> line (just after the <switch name="Switch_selectstore"> element):
38) Save the changes to the Fulfillment BPEL Process. In this section, you create one more Switch activity that checks the shipStatus in the outputVariable. In the <case> branch check if the shipStatus is completed and execute the Scope_shiporder activity. 39) In the Fulfillment.bpel Diagram window, collapse the Scope_checkstock and Scope_shiporder activities. 40) In the Fulfillment.bpel Diagram window, drag a Switch activity between the Scope_checkstock and Scope_shiporder activities. Rename the Switch to Switch_orderstatus.
41) Expand the Switch_orderstatus activity and configure with the following steps: a) Select and delete the <otherwise> branch. Note: Click Yes, when the Confirm Delete window is displayed.
b) Double-click the <case> branch title to open the Switch Case settings window, set Name to order completed? and create an expression that compares the shipStatus element of the outputVariable to the string literal value 'completed'. Use the following image as a guide:
c) Drag the Scope_shiporder into the <case order completed?> branch. Use the following image as a guide:
In this practice/task, you deploy the updated POProcessing composite application with all the changes made to the Fulfillment BPEL process. You perform the following tests: Submit an order that is fulfilled by the internal store. Submit an order that is fulfilled by the online store. Submit an order that cannot be fulfilled by any store. You initiate and monitor the results of these tests in Oracle Enterprise Manager. 1) In the JDeveloper Application Navigator, ensure that the POApplication and its projects are displayed.
3) In the SOA Deployment Configuration Dialog, select the Overwrite any existing composites with the same revision ID option, and click OK. Note: Monitor the Deployment Log window to ensure deployment is successful. 4) In a Web browser window, login to the Oracle Enterprise Manager page (URL http://localhost:7001/em), as the user weblogic with password welcome1. 5) On the Oracle Enterprise Manager SOA home page, expand the SOA folder in the Farm navigator, and click the POProcessing [1.0] link.
2) To deploy the POProcessing composite application, right-click the POProcessing project node and select Deploy > POProcessing > to > soaserver.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
d) Do not close the ipod_query.sql window, because you reuse the query on this page in subsequent practice steps. 7) On the POProcessing [1.0] Test Web Service page, under the Request tab Input Arguments section, select the XML View and perform the following steps: a) Replace the XML data with the contents of the file D:\labs\files\xml_in\po-medium-ipod.xml. b) Observe that the order has a quantity of 10 for products with the ID of SKU303 and SKU304. Then click Test Web Service. c) On the Response tab, click the Launch Message Flow Trace link. a) What is one indicator that can be used to quickly tell if the order was fulfilled? b) Which store was selected to fulfill the order? Explain your answer. Answers for Step 8. a. A quick indication that the order was fulfilled is to locate a row with a JMS Adapter component being executed. This indicates that the order was shipped, and therefore it must have been fulfilled by one of the stores. For example:
8) On the Flow Trace page, examine the Trace tree and answer the following questions:
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for Step 8. b. The InternalStore was used to fulfill the order request. This can be determined by the presence of the second occurrence of the InternalStore Reference row, with the ManageInventory BPEL Component containing four nested InternalStoreService Reference rows. Two of the InternalStoreService Reference rows are used to check if they can obtain the database product quantities and the second two entries are for updating the product quantities in the database. For example:
9) On the Flow Trace, verify your answers by clicking the Fulfillment BPEL Component link, and using the Instance of Fulfillment > Flow tabbed page, answer the following questions: a) In the Scope_checkstock activity flow, what was the response returned by the OnlineStore? Explain how you determined your answer. b) In the Scope_checkstock activity flow, what was the response returned by the InternalStore? Explain how you determined your answer. c) In the Scope_checkstock activity flow, what is the name of the first Assign activity in the Switch that appears after the parallel flow? Describe two ways to determine the answer. d) What are the carrier and shipStatus values returned as response in the callbackClient activity?
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for Step 9. a. The result return is out-of-stock. The result returned from the OnlineStore can be determined by clicking the Receive_onlinestore activity icon. In the Activity Details window, click the View xml document link:
In the Web browser window that is opened you can view the response message:
b. The result return is in-stock. The result returned from the InternalStore is determined by clicking the Receive_internalstore activity icon. In the Activity Details window, click the View xml document link:
In the Web browser window that is opened you can view the response message:
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for Step 9. c. The name of the first Assign activity in the Switch appearing after the parallel flow contained in Scope_checkstock, is called Assign_acquireinternal. You can determine the name either by moving and holding the mouse over the Assign icon or clicking the Assign icon. Clicking the icon displays the full activity name in the Activity Details window. The sample image demonstrates the first technique:
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for Step 9. d. The shipStatus value is completed, and the carrier is UPS. Click the callbackClient activity icon in the Flow page to view the values in the Activity Details window. For example:
10) In the JDeveloper window, display the updated stock quantity levels for the internal and online stores by performing the following steps: a) In the ipod_query.sql window, click the Execute Statement icon ( verify that you obtain the following results in the Results tab: ), and
Note: The original values for the product with SKU303 was 15 and SKU304 was 10. The order acquired a quantity of 10 for each product. Therefore, the database results of 5 and 0, respectively, are consistent with the processing performed. b) Do not close the ipod_query.sql window.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Test an Order Fulfilled by the Online Store
In this test you submit the po-medium-ipod.xml a second time with different quantity values and verify that the order is fulfilled by the OnlineStore, and verify that the stock quantity levels for the products order has been decreased. 11) On the POProcessing [1.0] Test Web Service page, click the Request tab. Note: The Input Arguments section should contain the XML data submitted in the previous test. If not then select the XML View and replace the XML data with the contents of the file D:\labs\files\xml_in\po-medium-ipod.xml. a) First update the <quantity> element values for both products to a value of 5. Use the following image as a guide:
b) After updating the new quantities, click Test Web Service. c) On the Response tab, click the Launch Message Flow Trace link. 12) On the Flow Trace page, examine the Trace tree and check if the order was fulfilled by the OnlineStore. Explain how you can verify the answer using the Flow tabbed page for the Fulfillment BPEL component instance. One Possible Answer: The online store was used to fulfill the order because the order requested a quantity of 5 for each product. The online store database has a quantity of more than 5 for each product. However, the internal store has a zero quantity for one of the products ordered. To verify the outcome: a) Click the Fulfillment link in the Trace tree.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
b) On the Instance of Fulfillment page, click the Flow tab. c) On the Flow tab, scroll down and click the Receive_internalstore activity. In the Activity Details window click the View xml document link. d) On the Web page that is opened the response from the internal store is out-ofstock for example:
f) On the Web page that is opened the response from the online store is in-stock for example:
13) On the JDeveloper ipod_query.sql tabbed page, click the Execute Statement icon and confirm that the ONLINE column has reduced the product quantities by a value of 5 for the two products SKU303 and SKU304 from 8 and 7 to the values 3 and 2, respectively. Use the following image as a guide:
14) Do not close the ipod_query.sql tabbed page in JDeveloper. 15) Close any Activity Details windows and Web pages that display the XML responses or Flow Trace pages.
e) On the Flow tab, scroll down and click the Receive_onlinestore activity. In the Activity Details window click the click the View xml document link.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
a) In the XML View of the Input Arguments section, replace existing data with text in the D:\labs\files\xml_in\po-large-ipod.xml file, and click Test Web Service. b) On the Response tab, click the Launch Message Flow Trace link.
17) On the Flow Trace page, and while viewing the Trace tree, how do you know that the order was not fulfilled by either of the stores? Use this image as a guide:
Answer: If you examine the rows under the Fulfillment BPEL Component you can see that there is no instance for a JMS Adapter service. This indicates the order was not shipped. In addition, there is not a second instance for either the OnlineStore or InternalStore. The presence of a second instance indicates the acquireStock operation is invoked. 18) On the Flow Trace page, click the Fulfillment link to examine the Audit Trail tabbed page on the Instance of Fulfillment page. Answer the following questions: a) What is the shipStatus response returned by the Fulfillment BPEL process? b) What is the XML response from the Receive_onlinestore? c) What is the XML response from the Receive_internalstore? d) Have the quantities for the products in the online and internal store database tables been changed by this instance of the POProcessing composite application? Explain your answer.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for step 18. a. The shipStatus response returned by the Fulfillment BPEL process is waiting. This indicates that the order cannot be fulfilled yet. To verify the response message, expand the <payload> part of the callbackClient in the Audit Trail tabbed page:
b. The response received from the online store is out-of-stock, as expected. To view the response, on the Audit Trail tabbed page scroll down and click the View XML Document link that appears below the Receive_onlinestore activity. For example:
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
Answers for step 18. c. The response received from the internal store is out-of-stock, as expected. To view the response, on the Audit Trail tabbed page scroll down and click the View XML Document link that appears below the Receive_internalstore activity. For example:
d. No. The quantities for the product with the ID of SKU305 have not been changed. Note: The po-large-ipod.xml order requested a quantity of 20 for the product with ID of SKU305. Neither store has enough quantity to fulfill the order.
Practice 9-6: Deploy and Test POProcessing with Stock Checks (continued)
b) In the ipod_update.sql window, click the Run Script icon ( any of the soademo connections. ), and select
c) In the ipod_update.sql window, under the Script Output tabbed section verify that you see following results:
d) In the ipod_update.sql window, click the Commit icon or press F11, to commit the database changes performed by the UPDATE statements.
e) In the ipod_query.sql window, click the Execute Statement icon ( ), and select any of the soademo connections. Verify that you obtain the following results in the Results tab:
20) Close the ipod_query.sql and ipod_update.sql windows. 21) Close any Web browser windows displaying a Flow Trace page.
The changes to the assembly model include: Create the CheckCCLimit BPEL Process component Create new wire between the ValidateCreditCard Mediator and CheckCCLimit BPEL Process components. Create a new wire between the CheckCCLimit BPEL Process and CreditCardDBService. Note: When creating new wires from the Mediator component you also need to create new transformation files. In this case, you also configure filters to ensure you direct the appropriate cards to the correct target service. You create the CheckCCLimit BPEL Process implementation to invoke the CreditCardDBService to get the credit card status and its credit limit, and check if the order total exceeds the credit limit. This is illustrated in the following image:
Note: If the order total exceeds the credit limit you throw a BPEL fault, which is
propagated to the Mediator component, and then to the composite application client, which is the ApproveCCOrder BPEL process in the POProcessing composite application. Finally, you modify the ApproveCCOrder BPEL process to handle the fault propagated for the credit limit error, as shown in the following image:
The ApproveCCOrder BPEL process handles the fault and sets the order status in the outputVariable response message to indicate the order is rejected.
2) In the JDeveloper Application Navigator, if needed expand the CreditCardValidation > SOA Content folder and double-click the composite.xml to open the assembly model in the Composite Editor window. 3) In addition, open the ValidateCreditCard.wsdl file in the WSDL Editor and answer the following questions: a) What is the name of the fault for the validateCC operation? Hint: Expand the validateCC operation node in the validateCC_ptt tree under the Port Types column, and select the fault node. The fault name can be found in Property Inspector, which may require you to click View > Property Inspector to be visible. b) What is the message name for the fault? Find two places where you can determine this information. c) What are the fault message type and part names? d) Where can you find the definition of the fault message type name, and what leaf child element name in the fault message type structure? Hint: Click the Imports button in the WSDL editor.
Note: To ensure the Property Inspector is visible, select View > Property Inspector.
With the Messages section expanded and the fault selected in the Port Types section, the message name and its definition is visible in the Messages section:
c. The message fault type name is CreditCheckFault, and the message fault part name is called fault in this case. The message type and part names are visible in the expanded message name entry listed under the Messages section of the WDSL Editor (refer to the last image in answer b.
4) Close the creditcheck.xsd and ValidateCreditCard.wsdl windows in JDeveloper. In this section you create a new BPEL component in the assembly model and use the ValidateCreditCard.wsdl for the BPEL component interface. Note: You use ValidateCreditCard.wsdl file for the interface to make the BPEL interface compatible with the ValidateCreditCard Mediator component and for the WSDL fault definition that is used in the BPEL process flow implementation. 5) In the composite.xml file with the CreditCardValidation assembly model, create a new BPEL Process component called CheckCCLimit and use the Base on a WSDL template. Ensure the BPEL Process component is not exposed as a SOAP service. Use instructions in the following table and associated screenshots:
Note: Clicking the Imports > creditcheck.xsd opens the XSD file in the XML Schema Editor, where you can expand the CreditCheckFault element and view its definition and child leaf node, which is named error:
b.
c.
a)
c)
10) Save the changes to the composite.xml file. In this section you add the filters and transformations needed to send credit cards to the appropriate target for processing. The filters ensure that credit cards beginning with the string 9000 are sent to the CreditCardDBService, and all other cards numbers are sent through the CheckCCLimit BPEL process first. 11) In the composite.xml window, double-click the ValidateCreditCard Mediator component icon to open it in the Mediator Editor window. 12) In the ValidateCreditCard.mplan window, to create the filter expression for the first routing rule section whose target is CreditCardDBService::CreditCardDBServiceSelect perform the following steps:
b) In the Expression Builder window, create the following expression: starts-with($in.request/inp1:CreditCheckRequest /inp1:CCNumber, '9000') Note: Enter the expression on a single line. Use the following image as a guide:
13) In the ValidateCreditCard.mplan window, to create the filter expression for the first routing rule section whose target is CheckCCLimit/checkcclimit_client::validateCC perform the following steps: a) In routing rule with the CheckCCLimit/checkcclimit_client::validateCC target, click the Invoke Expression Builder icon ( ) to the right of the <<Filter Expression>> field. b) In the Expression Builder window, create the following expression: not(starts-with($in.request/inp1:CreditCheckRequest /inp1:CCNumber, '9000'))
c) Save the changes to the Mediator component file. 14) In the ValidateCreditCard.mplan window, create the request message transformation for the BPEL component by performing the following steps: a) In the request section for the CheckCCLimit/checkcclimit_client::validateCC target, click the Select an existing mapper file or create a new one. icon ( ) next to Transform Using containing the text request: <<Transformation Map>>
b) In the Request Transformation Map window, select the Create New Mapper File option accepting the default name supplied, and click OK. c) In the CreditCheckRequest_To_CreditCheckRequest.xsl XLST Mapper window, map all source elements to their corresponding target elements. Use the following image as a guide:
d) Save the changes to the XSLT map and close the CreditCheckRequest_To_CreditCheckRequest.xsl XSLT Mapper window.
d) Save the changes to the XSLT map and close the CreditCheckResponse_To_CreditCheckResponse.xsl XSLT Mapper window. 16) In the ValidateCreditCard.mplan window, observe that the Mediator Editor has created the Fault section and already created a routing rule to return the fault (if it should arise) to the initial caller. Create the fault message transformation for the BPEL component by performing the following steps: a) In the Faults section for the *Initial Caller*::validateCCfault target, click the Select an existing mapper file or create a new one. icon ( ) for Transform Using with text fault: <<Transformation Map>>. b) In the Fault Transformation Map window, select the Create New Mapper File option accepting the default name supplied, and click OK. c) In the CreditCheckFault_To_CreditCheckFault.xsl XLST Mapper window, map all source elements to their corresponding target elements. Use the following image as a guide:
c) In the CreditCheckResponse_To_CreditCheckResponse.xsl XLST Mapper window, map the source elements to its corresponding target element. Use the following image as a guide:
In this practice/task, you create the CheckCCLimit BPEL Process implementation to invoke the CreditCardDBService to get the credit card status and credit limit for the given card number, and then for VALID cards check if the order total exceeds the credit limit. The process should throw an exception if the order total exceeds the credit limit. 1) In the composite.xml window, for CreditCardValidation, double-click the CheckCCLimit BPEL Component icon to open it in the BPEL Editor. In this section you create the main activities that form the BPEL process flow.
Purpose Copies the credit card number to CreditCardDBService request variable. Invokes the CreditCardDBService Copies the credit card status value from the CreditCardDBService response variable. Checks if the card status is VALID and if the order total exceeds the credit card limit returned with the CreditCardDBService response.
Note: These activities form the main process flow. In subsequent steps you configure the settings for each of the activities, and then add activities to throw the exception and propagate the exception message to the invoker of this BPEL process.
2) In the CheckCCLimit.bpel Design window, create the activity types and names in the order listed in the following table (between the receiveInput and replyOutput activities):
In this section, you expand the Switch and delete the <otherwise> branch. You create the condition in the <case> branch, and add and configure a Throw activity inside the <case> branch. 10) In the CheckCCLimit.bpel Design window, expand the Switch_cclimit activity and delete the <otherwise> branch. Use the following image as a guide to the result:
11) To configure the <case> branch condition, perform the following steps: a) Double-click the <case> branch title section. b) In the Switch Case settings window, set Name to check status and limit.
c) In the Switch Case Expression create a conditional expression (by using the Expression Builder) that compares the outputVariable status element to the casesensitive string literal 'VALID' and if the (order) amount in the inputVariable is greater than the creditLimit element in the Invoke_ccservice_CreditCardDBServiceSelect_OutputVariable. Important Note: Ensure that you enclose the values comparing the amount and creditLimit in the number() function to force the comparison to be based on the numeric value, otherwise the XML expression is compared based on the string values. Use the following image as a guide:
Note: The condition should resemble the following expression, showing where the number() function is applied and that the literal value 'VALID' is required to be in uppercase by highlighting them in bold and underline font:
bpws:getVariableData('outputVariable','reply','/ns3:CreditC heckResponse/ns3:status') = 'VALID' and number(bpws:getVariableData('inputVariable','request','/ns3 :CreditCheckRequest/ns3:amount')) > number(bpws:getVariableData('Invoke_ccservice_CreditCardDBS erviceSelect_OutputVariable','CreditcardsCollection','/ns4: CreditcardsCollection/ns4:Creditcards/ns4:creditLimit'))
d) Save the changes to you BPEL process Having detected the credit limit business fault, you throw a fault to terminate additional processing in this BPEL process. 12) To create and configure a Throw activity inside the <case> branch of the Switch_cclimit activity by performing the following steps:
Oracle SOA Suite 11g: Build Composite Applications 346
13) To configure the Throw_validateccfault activity, using the following image as a guide:
To edit the settings double-click the Throw_validateccfault icon and use instructions in the following table and associated screenshots: Step Screen/Page Description a. Throw > General tab Choices or Values To set the fault Namespace URI and Local Part in the Faults QName section, click the Browse Faults icon ( ). Expand the Project WSDL Files > ValidateCreditCard.wsdl entry, select validateCCfault and click OK. Observe that the Namespace URI and Local Part fields are filled in by your selection. Fault Variable: Click the Auto Create Fault
b. c.
a)
b)
d)
14) Save the changes to your BPEL process. In this section you create a Catch branch for the validateCCfault in the main process scope, and add an Assign activity to set a fault message that is sent to the invoker by using the fault variable in a Reply activity. Note: If you did not use a Reply activity with the fault information the invoker can still see the business fault. However, it is received as if it is a system fault. By using the Catch branch you are creating a robust error handling sequence.
16) To configure the Catch branch to handle the validateCCfault, double-click the Catch branch icon use the following image as a guide to the settings:
If needed perform the following steps to create the Catch settings: a) In the Catch window, in Faults QName, click the Browse Faults icon ( ). b) In the Fault Chooser, expand the Project WSDL Files > ValidateCreditCard.wsdl entry, select validateCCfault and click OK. c) In the Catch window, for Fault Variable click the Browse Variables icon ( d) In the Variable Chooser window, select creditFault and click OK. e) In the Catch settings window, click OK. 17) Save the changes to your BPEL process. ).
19) To configure the Assign_ccerror activity, double-click the Assign_ccerror icon and create a copy operation that stores the result of an expression, which concatenates the text ' Error: order total exceeds the credit limit of ' with the creditLimit element in the Invoke_ccservice_CreditCardDBServiceSelect_OutputVariable. Use the following image as a guide:
Note: The From value should resemble the following expression (noting the space at the end of the first string literal parameter in the concat function):
concat('Error: order total exceeds the credit limit of ', bpws:getVariableData('Invoke_ccservice_CreditCardDBServiceSele ct_OutputVariable','CreditcardsCollection', '/ns4:CreditcardsCollection/ns4:Creditcards/ns4:creditLimit'))
Note: if you require help to create the Reply activity settings, perform the following steps: a) In the Reply window, for Partner Link click the Browse Partner Links icon ( b) In the Partner Link Chooser window select checkcclimit_client and click OK. c) In the Reply window, for Variable click the Browser Variable icon ( d) In the Variable Chooser window, select creditFault and click OK. e) In the Reply window, in Fault QName, click the Browse Faults icon ( ). f) In the Fault Chooser window, expand the Project WSDL Files > ValidateCreditCard.wsdl entry, select validateCCfault and click OK. g) In the Reply window, click OK. 21) Save the changes to your BPEL process and CreditCardValidation composite application. ). ).
In this practice, you modify the ApproveCCOrder to handle the exception that can be returned when invoking the CreditCardValidation composite application as a service. If you do not handle the exception the process ungracefully terminates when the exception is detected. Handling the exception is done in the scope called Scope_validatecc, in which the ValidateCCService (external reference for the CreditCardValidation composite application) is invoked. Note: Creating the Catch block and fault handling is similar to what you did in the CheckCCLimit BPEL Process in Practice 10-2. In this case, you do not propagate the exception because it is handled by storing the rejected status in the outputVariable to track the occurrence of an exception. To complete the task of handling the validateCCfault, perform the following steps: 1) In the JDeveloper Application Navigator, if needed expand the POProcessing project > SOA Content tree and double-click ApproveCCOrder.bpel to open it in the BPEL Editor. In this section create a Catch block on the Scope_validatecc scope.
2) In the ApproveCCOrder.bpel Design window, create a Catch branch on the Scope_validatecc scope by clicking the Add Catch Branch icon ( ) on the scope sidebar. Use the following image as a guide:
3) To configure the Catch branch to handle the validateCCfault, double-click the Catch branch icon use the following image as a guide to the settings:
If needed perform the following steps to create the Catch settings: a) In the Catch window, in Faults QName, click the Browse Faults icon ( ). b) In the Fault Chooser, expand the Partner Links > ValidateCCService > Imported WSDL > ValidateCreditCard.wsdl entry, select validateCCfault and click OK.
c) In the Catch window, for Fault Variable click the Auto-create Fault Variable icon ( ).
4) In the ApproveCCOrder.bpel Design window, expand the Catch and add a single Assign activity into the Catch and rename it to Assign_rejected. Use the following image as a guide:
5) To configure the Assign_rejected activity, double-click the Assign_rejected activity icon and create a copy operation that stores the literal string 'rejected' in the order > status element of the process outputVariable. Use the following image as a guide for creating the copy operation:
1) In the JDeveloper window, to help with selecting credit cards and amounts for the tests display the credit card data by performing the following steps: a) In the Application Navigator, select the files application, expand the files > Application Sources > sql folder, and double-click creditcard_query.sql. b) In the creditcard_query.sql window, click the Execute Statement icon ( ). c) On the Select Connection dialog box, select the soademo (POApplication) connection, and click OK.
d) Confirm your results in the Results tab with the following image:
Note: The tests will use the second credit card row, credit card number 12341234-1234-1234 that has a credit limit of 20000. e) Close the creditcard_query.sql window. 2) In a Web browser window, login to the Oracle Enterprise Manager page (URL http://localhost:7001/em), as the user weblogic with password welcome1.
Oracle SOA Suite 11g: Build Composite Applications 358
In this practice, your tasks are to: Perform the following two tests of the CreditCardValidation composite application. o Test a valid card with an order amount less than the credit card limit o Test a valid card with an order amount exceeding the credit limit. Perform the following two tests of the of the POProcesssing composite: o Test an order with a valid card and order total less than the credit limit to verify normal processing occurs. o Test an order with a valid card and order total greater than the credit limit to test if the exception is correctly handled. To complete these tests perform the following steps:
b) On the Response tab, the reply status value displays the value VALID. This is expected. For example:
5) To perform the second test, click the Request tab, and perform the following steps: a) The CCNumber field should already have the value 1234-1234-1234-1234 and the amount contains 1000. Replace the amount with 22000 (this is 2000 above the credit limit), and click Test Web Service.
b) This time the Response page is not displayed. Instead the Webservice invocation failed window is displayed. Click Close.
6) On the CreditCardValidation [1.0] Test Web Service page, to return to the composite application home page click the SOA Composite > Home menu (at the top of the page). For example:
7) On the CreditCardValidation [1.0] home page, under the Dashboard tab you can click the link in the Instance ID column for the faulted instance.
Note: The Instances ID for a synchronous process instances are not normally visible in the Enterprise Manager Web page for production systems. However, since the Audit Level has been set to the Development setting (instead of Production) the faulted synchronous instance information is saved in the SOA Schema database tables. Otherwise, you would have to consult the log files for errors.
Note: The CreditCardValidation composite process validateCC operation is a synchronous interaction. Therefore, Oracle Enterprise Manager displays a Webservice invocation failed window when a synchronous service is initiated from the Web based testing tool. To find out what the cause is it is easier to locate the instance id in the Dashboard or Instances tab on the CreditCardValidation [1.0] home page.
8) On the Flow Trace page, examine the Trace tree shown in the image provided and answer the questions that follow the image:
a) Why is the CheckCCLimit BPEL Component not showing a Faulted value in the State column? b) How can you tell that the validateCCfault business fault has been propagated externally to the composite application?
In the Instance of CheckCCLimit Audit Trail page, scroll down and locate the Throw activity and observe that the fault is thrown and then caught, such that the final Assign and Reply activities are successfully executed to propagate the fault message to the invoker of the BPEL process:
On the Instance of ValidateCreditCard Audit Trail page, you can scroll to and locate the error when the 2-way operation validateCC is displayed. After the error is detected the Mediator performs a transformation of the fault message data received from the BPEL process and it performs a step showing Rethrowing fault after which the fully qualified QName for the validateCCFault is shown. This action is the indicated that the fault has been propagated externally.
Note: Now that you have tested the basic functionality for the CreditCardValidation composite application changes, you can proceed to perform similar tests in the context of the POProcessing composite application. If you have time, perform a final test case to test the credit card number (4321-43214321-4321) that has an INVALID status, and verify that the INVALID status is returned to the caller without performing a credit limit check for INVALID cards.
Note: If you desire confirm that the response from the ValidationCCService is the status of VALID. e) Close the Flow Trace Web browser window.
Oracle SOA Suite 11g: Build Composite Applications 364
c) On the Response tab, click the Launch Message Flow Trace link.
11) To perform a test with a valid credit card and an order total that exceeds the credit limit, on the POProcessing [1.0] Test Web Service page, click the Request tab and perform the following steps: a) In the Input Arguments section with the XML View selected, replace the XML data with the contents of the file D:\labs\files\xml_in\po-largeguitar.xml. b) Replace the quantity for both products to a value of 5 (five). This causes the order total to be 20500, which is 500 more than the credit limit of 20000 for this credit card. Click Test Web Service.
c) On the Response tab, click the Launch Message Flow Trace link. 12) On the Flow Trace page, confirm that the validateCCfault is thrown for the credit limit being exceeded for this order.
13) On the Flow Trace page, examine the Trace tree and answer the following questions: a) What is the final order status in outputVariable supplied to the callbackClient activity in the ApproveCCOrder BPEL process? Explain your answer. b) Was the order processed by the Fulfillment service? Explain your answer. c) Did the fault message get received by the ApproveCCOrder BPEL process?
Note: The reason why the status has been set to rejected is because the ApproveCCOrder BPEL process caught the fault condition. In the catch block the Assign_rejected activity sets the status. b. The Fulfillment BPEL process was not invoked by the ApproveCCOrder BPEL Process, because it does not appear in the Trace tree due to the Invoke_validatecc activity receiving the validateCCfault. This caused the Catch block to execute and end the process with the callbackClient activity. Therefore, the Fulfillment BPEL process was not invoked because its activity sequence could not be executed due to the fault handling implementation.
Note: However, that the fault message text is not saved anywhere, and can be viewed in the Audit Trail pages for the relevant component instances.
14) Close the Flow Trace and any Activity Detail window you have opened.