OPN Oracle SOA Suite 11g Implementation Boot Camp

start the tutorial at any chapter, beginning with the solution for the previous chapter. In addition .... if manual approval is required and seeks human approval using a Human Task component. ... Other directories and files used during the exercises ... cd ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sql sqlplus.
25MB taille 2 téléchargements 277 vues
THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Activity Guide

D64982GC20

Edition 2.0

December 2010

Oracle University and Digora use only

OPN Oracle SOA Suite 11g Implementation Boot Camp

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. Government’s 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.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Copyright © 2010, Oracle and/or its affiliates. All rights reserved.

End-2-End Purchase Order Processing

Table of Contents 1. Introduction and Setup 2. Creating the Credit Card Validation Service 3. Creating the Purchase Order Routing Service 4. BPEL Orchestration 5. Modifying the Mediator 6. Adding Human Workflow 7. Adding Business Rules 8. Adding Fulfillment 9. Adding JMS to Fulfillment A. Deploying and Running applications B. Managing the lifecycle of a SOA composite application C. Unit Testing D. Fault Handling E. Enforcing Policies F. Handling Business Events using EDN G. Using Service Data Objects (SDO) H. Adding BAM Activity Sensors I. Integrating with Oracle B2B J. Virtualize the Credit Validation Service on Oracle Service Bus

Oracle Confidential. For authorized use only. Do not distribute to third parties.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

SOA Suite 11g Boot Camp

End-2-End Purchase Order Processing

1.1 Introduction In this tutorial you will build a SOA composite application to process and approve purchase orders. The purchase order details can come in from any source (in our case a testing page), the credit card status for the customer is validated and if the credit card is good, the order continues. An order for a large purchase price requires a manual approval step. Finally, the order is written to a text file to be processed by the fulfillment house. For approved orders, the order is sent to the fulfillment carrier. This SOA composite application contains a database adapter, file adapter, JMS adapter, Web services binding, mediator routing, BPEL process, Business Rule, and Human Task. It introduces each component with a minimum of complexity. The complete application is built in 9 steps. There are three setup steps required before you begin: 1) install the database schema, 2) create the JMS resources, and 3) create the database resources. These setup steps are described later in this chapter.

1.2 How to use this tutorial This tutorial was written to provide the most flexibility for all types of users. The ready-to-deploy solution at the end of each chapter is available so you may choose to start the tutorial at any chapter, beginning with the solution for the previous chapter. In addition, the instructions for each chapter are written at three levels of complexity: 1) detailed step by step instructions, 2) high level functional and design notes, and 3) quick-build list of objects. This tutorial can be used in the following ways.

Section 1.1

1.

As a demo – You complete the setup described in this chapter and deploy chapter 9 to skip design time and to demo the multiple components of this application. Go to the solutions folder for Chapter 9 to get the composites you need to deploy. If needed, see Appendix A for more details on running the servers, deploying, and testing the application.

2.

Complete tutorial for new users – You complete each chapter sequentially using the step by step instructions. When you are finished, you will have an introduction to all of the many components of this application, both design and runtime. This complete tutorial takes 4-6 hours, depending on your level of experience.

3.

Selected tutorial for all users – To run any single chapter to learn about a particular component, first complete the setup in this chapter and then simply open the solution from the previous chapter and begin the next chapter. The time to complete a chapter takes from about 10-60 minutes, depending on your experience.

4.

Tutorial for advanced users – If you have experience with SOA 10g and or 11g you may choose to design the solutions using only the introduction and design notes available with each chapter. These notes describe the functional aspects of the chapter and some details on the solution design. Of course, the advanced user End-2-End Purchase Order Processing 1-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

1

5.

Quick build – Most chapters include a final section called Operations and naming which lists the objects and their names used in the chapter. Experienced users can use this quick-build list of objects to build the designed solution quickly, completing the entire application in less than 2 hours.

1.3 Description of the application The application you will build is the back-end processing of a new order. The business process to be implemented is as follows.



All orders will be written to a text file for later reference.



Small orders (defined as those under $1,000) are to be automatically approved.



Large orders (those greater than or equal to $1,000) go through a validation and approval process.

-

The customer's credit card must be validated.

-

If the order is $5,000 or more, a customer service representative must manually approve the order.



Approved orders shall have the status "approved".



Large orders with an invalid credit card shall have the status "invalidCreditCard".



Large orders rejected by the customer service representative shall have the status "rejected".



All approved orders are sent to the fulfillment service which uses the order value to determine the fulfillment vendor: = 1000 and < 5000 goes to UPS, > 5000 goes to FedEx.

Figure 1 shows a visual representation of the business process.

1-2 End-2-End Purchase Order Processing

Section 1.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

could design the solution as desired. The time to complete this challenge for experience users varies with their level of experience.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Figure 1 Visual view of the business process

Section 1.3

End-2-End Purchase Order Processing 1-3

In terms of the SOA application, you will create the following



A service that accepts new orders in XML format.



A File Adapter service that can write XML messages (such as orders) to a file.



A BPEL service implementing the large order process



The credit card validation service used by the large order BPEL service to validate a given credit card.



A Database Adapter service used by the credit card validation service to retrieve the status of a given credit card from the database.



A BPEL service implementing the Fulfillment process



A JMS adapter service that produces messages for the fulfillment vendors



A content-based Mediator service to route small orders to the file adapter and fulfillment process and large orders to the large order process.



The large order BPEL service also uses a Business Rule component to determine if manual approval is required and seeks human approval using a Human Task component.



The Fulfillment BPEL service also uses a Business Rule component to determine the fulfillment vendor.

1.4 Prerequisites This tutorial requires the following:



Desktop or laptop machine with Internet access and a web browser.



Access to the Oracle PartnerNetwork (OPN) Enablement Environment (OPNEE), a remotely-hosted, Linux-based environment where Oracle SOA Suite 11g software has been installed and configured for you. All lab exercises assume that you will be working in the OPNEE environment and not with Oracle software installed on your local machine.



Internet Explorer on you local desktop or laptop machine if you want to do the Oracle BAM lab



Lab materials, in the remote OPNEE environment, see: /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po

1.5 Project Files The lab materials po directory contains several directories and files:



input – a few files with sample input data



sql – database scripts used during setup



schemas – xsd files used when defining services



solutions – solution projects for each chapter

1-4 End-2-End Purchase Order Processing

Section 1.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

1.3.1 SOA Components

Other directories and files used during the exercises

1.6 Setting up the tutorial This tutorial requires database and JMS resources setup.

1.6.1 Installing the database schema This demo requires a table in the database owned by the soademo user. 1.

Make sure your database is running by right-clicking on the Start Database icon on the desktop and selecting the Open option. No feedback is given.

2.

In a Terminal window, create the soademo user. It is ok to run this script even if the soademo user already exists. . /home/oracle/bin/oracle_xe_env.sh cd ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sql sqlplus SQL> connect SQL> Enter user-name: sys as sysdba SQL> Enter password: bootcamp SQL> @create_soademo_user.sql You’ll see the message: “Grant succeeded” and then will be disconnected from the database.

3.

Now, in the same terminal window, create the credit card info table. It is ok to run this script again even if the table already exists. Be sure to run it with the soademo user for proper ownership. sqlplus soademo/soademo @create_creditrating_table.sql You’ll see the message: “1 row created” 4 times and then will be disconnected from the database. Don’t worry if you see a “name is already used” message as the table may have already existed. Exit the terminal window.

1.6.2 Creating the JMS resources This application requires a JMS resource. You create this using the WebLogic Server console. First you create the JMS queue and connection factory and then a connection pool for that connection factory. 1.

Section 1.6

Make sure your server is started by opening the Start/Stop Weblogic Server(s) icon on the desktop. Click the Start radio button and click OK. When prompted for which servers to start, select SOA and click OK. Watch the window for feedback that the server has started.

End-2-End Purchase Order Processing 1-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED



In a browser, open http://localhost:7001/console by clicking on the Admin Console bookmark on the toolbar to start the WebLogic Server Administration Console. Login using weblogic/welcome1.

First add the JMS Queue. 3.

In the WLS console, on left navigation bar, expand Services > Messaging and click JMS Modules.

4.

Click SOAJMSModule (click on the name, not the checkbox)

5.

In the Summary of Resources table, click New

6.

Select the resource type: Queue and click Next

7.

Enter name: demoFulfillmentQueue and JNDI name: jms/demoFulfillmentQueue

8.

Click Next

9.

Select Subdeployment SOASubDeployment

10. Select JMS Server SOAJMSServer 1-6 End-2-End Purchase Order Processing

Section 1.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

2.

means that the queue was already setup for you. Now add the Connection Factory. 12. In the Summary of Resources table, click New 13. Select the resource type: Connection Factory and click Next 14. Enter name: demoCF and JNDI name: jms/demoCF.

15. Click Next 16. Click Finish. You may see an error message. This probably indicates that the

connection factory was already setup for you. Move on.

Section 1.6

End-2-End Purchase Order Processing 1-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

11. Click Finish. You may receive a message that the “bean already exists.” This

Now add the connection pool. The connection pool is configured in the JMSAdapter application and uses a Deployment Plan. First, create a directory to contain that plan. 17. In the left navigation bar of the WLS console, click Deployments 18. Click JMS Adapter (click on the name, not the checkbox) 19. Click the Configuration tab and then the Outbound Connection Pools tab

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

You should see both the queue and the connection factory listed in the Summary of Resources as shown here.

20. Click New 21. Select the factory oracle.tip.adapter.jms.IJmsConnectionFactory

22. Click Next 23. Enter eis/Queue/demo.

1-8 End-2-End Purchase Order Processing

Section 1.6

Go back to the new connection pool to hook up the connection factory 25. Click the Configuration tab 26. Expand the factory: oracle.tip.adapter.jms.IJmsConnectionFactory 27. Click on eis/Queue/demo

28. View the cell on the far right for the property ConnectionFactoryLocation to see

that it contains the value jms/demoCF.

29. Click Save. You must use the Save button to save the value. Section 1.6

End-2-End Purchase Order Processing 1-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

24. Click Finish

31. Select the checkbox next to JMSAdapter 32. Click Update at the top of the Deployment table. 33. Verify that the correct deployment plan is selected

34. Click Next 35. Click Finish

1.6.3 Creating the database resource This application requires a database data source. You create this using the WebLogic Server console. First create the data source and then a connection pool for that data source. 36. If it isn’t already open, open the WebLogic Server Administration Console

http://localhost:7001/console and login using weblogic/welcome1. 37. On the left navigation bar, Click Services > JDBC > Data Sources. 38. In the data source table, click New. 39. Enter the data source information

Name: soademoDatabase JNDI Name: jdbc/soademoDatabase Database Type: Oracle The Database driver defaults to the correct driver: Oracle’s Driver (Thin XA) for Instance connections 40. Click Next, click Next again. You will receive an error message that “a data source

with this name already exists,” to indicate that the data source is already set up for you. Click Cancel. Here are the details that have already been setup for you for the data source: Database Name: XE (your database SID) Host name: localhost (host where your database is running) 1-10 End-2-End Purchase Order Processing

Section 1.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

30. Now the adapter must be redeployed. Click Deployments in the left nav bar.

Now create the connection pool. You have to edit the database adapter application and it uses a Deployment Plan. 41. In the left navigation bar, click Deployments. 42. Click the DbAdapter application (click the name, not the checkbox) 43. Click the Configuration tab, and then click the Outbound Connection Pools tab. 44. Click New 45. Select the radio button for javax.resource.cci.ConnectionFactory and click Next 46. Enter the JNDI Name as follows: eis/DB/soademoDatabase

Note that this is not the same value as in above step. It must match the value you enter in your database connection you create when building your application later using JDeveloper. 47. Click Finish 48. Now, edit the connection pool to reference the data source. Click the Configuration

tab, expand the connection factory and click your new connection pool: eis/DB/soademoDatabase (click on the name, not the checkbox) 49. In the Properties table, view the box to the far right of xADataSourceName to see

that it specifies: jdbc/soademoDatabase. 50. Go back to the main Deployments page to Update the DbAdapter. Click

Deployments in the left navigation bar. 51. Select the checkbox next to DbAdapter. 52. Click Update. 53. Select Redeploy this application and confirm the deployment plan location.

54. Click Finish Section 1.6

End-2-End Purchase Order Processing 1-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

Port: 1521 (set according to your configuration) Database user name: soademo (created in previous section) Database user password: soademo

DbAdapter > Configuration > Outbound Connection Pools and expand the connection factory listed there. You are ready to start building the SOA composites. Continue with Chapter 2.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

55. Confirm that the connection pool is added by going back to the Deployments >

1-12 End-2-End Purchase Order Processing

Section 1.6

2

2

Creating the Credit Card Validation Service

Creating the Credit Card Validation Service ...................................................................... 1 2.1 Introduction...................................................................................................................... 1 2.2 Designing the flow .......................................................................................................... 2 2.3 Creating a new application ............................................................................................ 2 2.4 Adding the database adapter ......................................................................................... 6 2.5 Adding the Mediator Component ............................................................................... 16 2.6 Adding a transformation to the Mediator component ............................................. 25 2.7 Deploying the application ............................................................................................ 28 2.8 Testing the application.................................................................................................. 28 2.9 Operations and naming ................................................................................................ 30

2.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solut ions/ch2-DBAdapter. To run this solution, you must first complete Chapter 1 to set up the application. In this section you will build a simple credit service. This service will look up the status (valid or invalid) of a given credit card from a database. The implementation of this service uses a Mediator to route the request to the database adapter that executes the query on the database and returns a result. Once done, your Mediator flow will look like this.

Section 2.1

Creating the Credit Card Validation Service 2-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.2 Designing the flow You will create a new composite application that will be invoked as a service from your main application to be designed later. This synchronous composite queries the database for the credit card number and returns its status.

2.3 Creating a new application 1.

Start JDeveloper by right-clicking on the JDeveloper icon on the desktop and selecting the Open option. When prompted for role, accept the Default Role.

2.

Create a new application. There are various ways and shortcuts to do this, and in this case choose File > New… from the menu.

3.

Select All Technologies in the top tab if present (only if you have a project open).

4.

From the Categories tree, click on General (don’t expand it).

5.

Select Generic Application from the Items field.

2-2 Creating the Credit Card Validation Service

Section 2.2

Section 2.3

6.

Click OK.

7.

In the subsequent Create Generic Application dialog set the following fields, leaving the others with their default values:



Application Name: CreditCardValidation



Directory (accept the default): /home/oracle/jdeveloper/mywork/CreditCardValidation

Creating the Credit Card Validation Service 2-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.

Click Next.

9.

When you create a new application you are prompted to create a new project. Set the following fields:



Project Name: validationForCC



Directory: (accept the default)



Project Technologies: SOA (use the arrow to add SOA to the Selected panel)

2-4 Creating the Credit Card Validation Service

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 2.3

10. Click Next. 11. The next step allows you to choose to start with an empty composite,

or with a component already added. In this case, select Empty Composite. 12. Click Finish.

Section 2.3

Creating the Credit Card Validation Service 2-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

13. You will now have an empty canvas displaying three swim lanes:

services, components, and references.

2.4 Adding the database adapter 1.

You can now start building the application. Drag-and-drop a database adapter onto the External References swim lane. If you don’t have the Component Palette open, from the menu select View > Component Palette. If the Component Palette is not showing the SOA components, select SOA from the drop down list.

2-6 Creating the Credit Card Validation Service

Section 2.4

2.

This database adapter call will return a result of valid or invalid for a given credit card from the database. A wizard takes you through the steps of configuring the database adapter. The title bar of the wizard dialog shows the step number. Click Next on step 1.

3.

Enter the following details on step 2:



Section 2.4

Service Name: getCreditValidation

Creating the Credit Card Validation Service 2-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click Next to go to step 3.

5.

The database adapter will connect to the database, and in order to do that it needs a database connection which contains all the details needed to connect to the database. You can pre-create a database connection or create one on the fly. Since a database connection hasn’t been created yet, you will create one from here.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Click the green plus icon to the right of the Connection drop-down list to create a new database connection.

2-8 Creating the Credit Card Validation Service

Section 2.4

6.

Section 2.4

In the Create Database Connection dialog, enter the following details:



Connection Name: soademoDatabase



Connection Type: Oracle (JDBC)



Username: soademo



Password: soademo



Save Password: Checked



Enter Custom JDBC URL: Unchecked



Driver: thin



Host Name: localhost



JDBC Port: 1521



SID: XE

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

Click the Test Connection button and verify that your connection works. Look for the message: ‚Success!‛

8.

Click OK to return to step 3 of the Database Adapter Configuration wizard.

Creating the Credit Card Validation Service 2-9

9.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Make sure the JNDI Name matches the data source connection pool JNDI Name you entered in Chapter 1. That is eis/DB/soademoDatabase. Click Next.

10. Set the following fields:



Perform an Operation on a Table: Selected



Select: Checked

All other fields should be unchecked.

2-10 Creating the Credit Card Validation Service

Section 2.4

11. Click Next. 12. In step 5 of the wizard, click the Import Tables button and then click

the Query button to retrieve the list of tables for the soademo user from the database. If you do not see any tables, go back to Chapter 1 to make sure the tables were created properly. 13. Select the CREDITCARDINFO table and move it to the Selected

field by pressing the Add (arrow) shuttle button.

14. Click OK. 15. Back in step 5 of the Database Adapter Configuration wizard, click

the CREDITCARDINFO table to select it.

Section 2.4

Creating the Credit Card Validation Service 2-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

16. Click Next. 17. Step 6 of the wizard lets you override or define the primary key for

your table. In this case no primary key is defined in the database, so you’ll need to specify it. Check CCNUMBER and leave the rest unchecked.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

18. Click Next. 19. Step 7 lets you define relationships if you are selecting from multiple

tables. Since there is only a single table in our exercise here, there is no relationship to define. 20. Click Next.

2-12 Creating the Credit Card Validation Service

Section 2.4

21. Uncheck all fields, in step 8, except status. That is the only column

we want to query from the database.

22. Click Next. 23. Step 9 is where you can specify your selection criteria. In this case

you will add a parameter to the query. The parameter will be set at runtime to select the row for the credit card you want. Click the Add button to add a new parameter called ccnb. Click OK.

Section 2.4

Creating the Credit Card Validation Service 2-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

24. Now, back in step 9, click the Edit button to bring up the Expression

Builder dialog and click the Add button to add a new condition

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

25. Press the Edit button in the First Argument section (lower-left corner

of the window). 26. In the Query Key dialog select ccnumber.

2-14 Creating the Credit Card Validation Service

Section 2.4

27. Click OK. 28. In the Second Argument section (lower-right portion of window),

select Parameter. 29. Ensure ccnb is selected in the drop-down list.

30. Click OK. 31. Back in step 9 of the wizard, you see the summary of the query that

you specified. The parameter ccnb will be populated at runtime and the query will select a row based on that parameter

Section 2.4

Creating the Credit Card Validation Service 2-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

32. Click Finish.

The database adapter will process your choices and generate a service that implements the operation you specified, which means your project will now contain a new WSDL file to represent that service: getCreditValidation.wsdl. The composite diagram has been updated with this service.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.5 Adding the Mediator Component The Mediator is the component in charge of routing in the SOA Suite. You will add a Mediator component to route a request to the getCreditValidation service you just created that uses the database adapter. 1.

Drag a Mediator component onto the composite diagram in the Components swim lane.

2-16 Creating the Credit Card Validation Service

Section 2.5

2.

In the Create Mediator dialog, specify these settings:



Name: RouteRequest



Template: Define Interface Later

A typical composite application will have many components, but only some of them will have a publically exposed web services interface. The composite editor in JDeveloper gives you the flexibility to define the interface now, choose an existing interface, or to define the interface later. We’ll elect to define the interface later.

Section 2.5

3.

Click OK.

4.

You will create a Web Service interface to expose this service using SOAP bindings. Drag a Web Service adapter to the Exposed Services (left-side) swim lane.

Creating the Credit Card Validation Service 2-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

In the Create Web Service dialog that appears, set the following fields:



Name: getStatusByCC



Type: Service

6.

Click the cog icon next to the WSDL File field to define the interface.

7.

The Create WSDL dialog lets you specify the message invocation types for the service. You have been given an existing XML schema definition (XSD) that specifies the types of the input and output for the service which you will reuse for this application.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Click the magnifying glass icon to the right of the URL field to browse for the provided schema file.

2-18 Creating the Credit Card Validation Service

Section 2.5

8.

In the Type Chooser dialog, click the Import Schema File button. It

is the left-most icon in the upper-right corner of the window.

9.

In the Import Schema File dialog, click the magnifying glass to browse for the schema file.

10. In the SOA Resource Lookup, make sure File System is selected. 11. Navigate to and select

~/SOA11gFoundationTutorial/SOA11gFoundationTutorial /po/schemas/creditcheck.wsdl.

Section 2.5

Creating the Credit Card Validation Service 2-19

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

12. Click OK. 13. Back in the Import Schema File dialog, make sure Copy to Project is

selected.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

14. Click OK. 15. In the Localize Files dialog, deselect Maintain original directory

structure for imported files and click OK. 16. Back in the Type Chooser dialog, expand the Project Schema Files >

creditcheck.xsd nodes. 17. Select creditcardStatusRequest.

18. Click OK.

2-20 Creating the Credit Card Validation Service

Section 2.5

19. The Create WSDL dialog is as shown. Do not click OK yet!

20. In a similar way, we’ll set the message types for the reply and fault

to creditcardStatus and error. The only difference is that you don't need to import the schema definition again because it's now part of your project. Proceed to set the message types for reply and then, fault: Click the Reply tab. 21. Click the flashlight icon to the right of the URL field. 22. Expand the Project Schema Files > creditcheck.xsd nodes. 23. Select creditcardStatus.

Section 2.5

Creating the Credit Card Validation Service 2-21

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

24. Click OK.

25. The reply message definition is as shown.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

26. Click the Fault tab. 27. Using the same method, select the error type. The Fault message

definition is as shown.

2-22 Creating the Credit Card Validation Service

Section 2.5

28. Click OK to close the Create WSDL dialog. 29. The Create Web Service dialog should now look like the illustration

below. Be careful here -- If you click the cog icon again you will have to set all three of the invocation types again (request, reply, and fault).

30. Click OK. 31. Now the components can be connected -- or "wired" -- together. Wire

the inbound web service binding to the Mediator component by clicking and dragging the mouse cursor between the two connection points:

Section 2.5

Creating the Credit Card Validation Service 2-23

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

32. Wire the Mediator component to the database adapter service:

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

33. You may be prompted to choose the operations (only if you selected

more than one database operation when you set up the database adapter service). If so, use these settings:



Mediator Operation: execute



Target Operation: getCreditValidationSelect

34. Click OK. 35. The composite diagram gives an overview of your application.

2-24 Creating the Credit Card Validation Service

Section 2.5

2.6 Adding a transformation to the Mediator component In this section you will modify the RouteRequest Mediator component to do an XSLT transformation on the message payload. That's because the incoming message to our publicly exposed service (getStatusByCC) is in a different format than the service created by the database adapter (getCreditValidation). Not only does the Mediator route requests between endpoints (which you did by wiring them together) but it can also transform the data as it passes through. 1.

Section 2.6

One way to drill down into a specific component is to double-click it from the composite diagram. You can also right-click it and select the Edit option. Double-click the RouteRequest Mediator component to open the Mediator editor. The RouteRequest.mplan window displays.

Creating the Credit Card Validation Service 2-25

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Click the transformation icon to the right of the Transform Using field in the request section (that's the first Transform Using field).

3.

Select Create New Mapper File and accept the default name.

4.

Click OK to open the mapping editor.

5.

Expand all the nodes on both sides. You can do it manually, or rightclick and select Expand All. Do the same for on the right-hand side.

6.

Map CCNumber from the source side to ccnb on the target side by dragging a wire from one element to the other.

2-26 Creating the Credit Card Validation Service

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 2.6

7.

Save All (second diskette icon in the upper-left corner of the main window) and close the mapper by selecting the close window icon on the right side of the tab. You may need to use the tab bar scroll buttons to navigate right to get to the close window icon. Alternatively you can press Ctrl-S to save the mapping, then Ctrl-W to close it.

8.

Back in the Mediator editor for the RouteRequest.mplan, click the transformation icon to the right of the Transform Using field in the Synchronous Reply section (that's the second Transform Using

field).

9.

In the Reply Transformation Map dialog, select Create New Mapper File and accept the default name.

10. Click OK to open the mapper. 11. Expand all the source and target nodes. 12. Map status from the source to creditcardstatus from the target.

Section 2.6

Creating the Credit Card Validation Service 2-27

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

13. Save and close the mapper to return to the Mediator editor.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

14. Save and close the Mediator editor to return to the composite

diagram. You can use the toolbar buttons or the menu, or simply press Ctrl-S to save and Ctrl-W to close this tab.

2.7 Deploying the application The first design iteration is complete and you are now ready to deploy the composite. The steps to run and test a composite application are explained in Appendix A Deploying and Running a Composite Application. Read that document now if this is the first time you are running and testing a composite application. Appendix A follows Chapter 9. Perform sections A.1 through A.4 before moving on here.

2.8 Testing the application For additional details regarding testing an application, read the steps in Appendix A in section A.7 titled “Running and testing the application with EM.‛ However, for now, perform the following steps to see your new application at work: 1.

After you have deployed your composite, open Enterprise Manager at the following link: http://localhost:7001/em or use the Enterprise Manager bookmark in your browser.

2.

Click the validationForCC link in the SOA section under soa-infra.

2-28 Creating the Credit Card Validation Service

Section 2.7

Section 2.8

3.

Open the Test page by clicking the Test button at the top-right of the left-window. Scroll down to the Input Arguments section and make sure that TreeView is selected.

4.

In the CCNumber field, enter a credit card number. In this case, enter 1234-1234-1234-1234 in the CCNumber field which is a valid credit card and returns the status, ‘VALID.’

5.

Click the Test Web Service button. Creating the Credit Card Validation Service 2-29

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

You will get a response from the service which will indicate if the credit card is valid or not. Here is the output for a valid credit card:

7.

Click Launch Message Flow Trace to see the details of the message flow for this instance of your composite. This displays a new window with the flow trace.

8.

Close the Flow Trace window.

9.

Try another value by clicking the Request tab. This time, enter 43214321-4321-4321 in the CCNumber field which is an invalid credit card.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Click the Test Web Service button to see the output. You’ll see that

this time, the reply value is INVALID. 11. In an upcoming chapter, you will create a new application that calls

this service, so you'll need to know the WSDL location for it. You can see the WSDL location listed in the WSDL field at the top of the Test page. In this case, it looks something like: http://localhost:8001/soa-infra/services/CreditCardValidation/ validationForCC/getStatusByCC?WSDL

2.9 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document.

2-30 Creating the Credit Card Validation Service

Section 2.9

Section 2.3 Creating a new application



Application Name: CreditCardValidation



Directory: /home/oracle/jdeveloper/mywork/CreditCardValidation



Project Name: validationForCC



Directory: /home/oracle/jdeveloper/mywork/CreditCardValidation /validationForCC



Project Technologies: SOA



Empty Composite

Section 2.4 Adding the database adapter



DbAdapter Service Name: getCreditValidation



Create Database Connection details:

-

Connection Name: soademoDatabase

-

Connection Type: Oracle (JDBC)

-

Username: soademo

-

Password: soademo

-

Save Password: Checked

-

Enter Custom JDBC URL: Unchecked

-

Driver: thin

-

Host Name: localhost

-

JDBC Port: 1521 (or the port number of your database)

-

SID: XE (or the SID of your database)

-

Jndi name: eis/DB/soademoDatabase



Operation: Select



Import CREDITCARDINFO table



Primary key CCNUMBER



Attribute Filtering: status



Add a new parameter: ccnb



Add Where clause: ccnumber = #ccnb

Section 2.5 Adding the Mediator Component

Section 2.9



Create Mediator: RouteRequest



Template: Define Interface Later Creating the Credit Card Validation Service 2-31

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



Create Web Service: getStatusByCC



Type: Service



WSDL based on: ~/SOA11gFoundationTutorial /SOA11gFoundationTutorial/po/schemas/creditcheck.xsd



Request: creditcardStatusRequest



Reply: creditcardStatus



Fault: error



Wire: service to mediator to adapter

Section 2.6 Adding a transformation to the Mediator component



Mediator transform: Map CCNumber from the source side to ccnb



Mediator transform for reply: Map status from the source to creditcardstatus from the target.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

The application is completed. Continue with Section 2.7 above to deploy and test your application.

2-32 Creating the Credit Card Validation Service

Section 2.9

3

3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10

Creating the Purchase Order Routing Service

Introduction .................................................................................................................................................... 1 Designing the flow ......................................................................................................................................... 2 Creating a new application ........................................................................................................................... 2 Adding the service interface ......................................................................................................................... 4 Adding the routing component ................................................................................................................... 9 Adding the File Adapter ............................................................................................................................... 9 Wiring the components and adding a transformation ............................................................................14 Deploying the application ...........................................................................................................................18 Testing the application .................................................................................................................................18 Operations and naming .............................................................................................................................21

3.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch3-FileAdapter. This solution does not require any setup. You will now create another application that will accept new purchase orders and forward them to the ordering system’s archive. In this case you will simulate the archive with a file adapter that will capture to disk all processed purchase orders. Ultimately, you will continue adding features to this composite application and expand it to implement the full PO Processing application following the chapters of this tutorial. For now, you begin with the first part, the archive. The implementation of this service uses a Mediator that receives orders coming over SOAP and writes them to file using the file adapter. Once completed, your composite application will look like Figure 1 PO Processing service.

Section 3.1

Creating the Purchase Order Routing Service 3-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Figure 1 PO Processing service

3.2 Designing the flow This service is a one-way service, also called fire-and-forget. It does not return any value. It takes a PurchaseOrder defined in po.xsd and writes data to a file using type Order defined in internalorder.xsd. Data transformation from type PurchaseOrder to Order is aided by a pre-defined dictionary named po2internalorders-dictionary.xml (available in your schemas directory).

3.3 Creating a new application 1.

Create a new application for your POProcessing composite. As an alternative, instead of using the File/New menu, choose New Application from the application list menu.

3-2 Creating the Purchase Order Routing Service

Section 3.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 3.3

2.

Name your application POProcessing and accept the default directory location.

3.

Click Next.

4.

Name the project POProcessing and select SOA for the Project Technologies.

Creating the Purchase Order Routing Service 3-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Click Next and then click Finish to create the project with an empty composite.

3.4 Adding the service interface 1.

Start by creating the service you will use to expose this composite over SOAP. Drag and drop a Web Service activity onto the Exposed Services swim lane

2.

Name it receivePO and create a WSDL from a schema by clicking the cog icon. Creating a WSDL from a schema allows you to define the input data that your service expects and at the same time, automatically create the WSDL interface.

3-4 Creating the Purchase Order Routing Service

Section 3.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Use the magnifying glass icon and then the Import Schema File icon to browse for the po.xsd schema (which you'll find under ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sche

mas), copy it to your project and open it to select the type.

Section 3.4

Creating the Purchase Order Routing Service 3-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3-6 Creating the Purchase Order Routing Service

Section 3.4

4.

Select the PurchaseOrder element. This is the input data for your service. Click

OK. This service is a one-way invocation type, also known as a fire-and-forget service. So there is no need to specify a reply or callback.

Section 3.4

Creating the Purchase Order Routing Service 3-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Click OK.

6.

Click OK to close the web service binding dialog. The receivePO exposed service is added to your composite.

3-8 Creating the Purchase Order Routing Service

Section 3.4

3.5 Adding the routing component 1.

Now, add a Mediator to the composite by dragging one from the palette to the canvas. Call it routePO and select the Define Interface Later template. When you define the interface later, you can graphically connect the SOAP service front end and file adapter service reference. The interfaces are implicit.

2.

Click OK.

3.6 Adding the File Adapter 1.

Section 3.5

Drag-and-drop a File Adapter to the External References swim lane. This file adapter will write each new order to a text file.

Creating the Purchase Order Routing Service 3-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Click Next in the Step 1 wizard window, and then, name the service WriteApprovalResults in Step 2 of the wizard.

3.

Click Next.

4.

Select the option to Define from operation and schema (specified later)

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

This feature allows you to use the file operation and schema to define the WSDL automatically. Alternatively, you could use an existing WSDL file if you had one already created for the service reference.

3-10 Creating the Purchase Order Routing Service

Section 3.6

5.

Click Next.

6.

Select the Write File operation.

7.

Click Next.

8.

Specify the following settings, leaving all others with their default values:



Section 3.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Directory for Outgoing Files: /home/oracle/tmp

Creating the Purchase Order Routing Service 3-11



9.

File Naming Convention: order_%SEQ%.txt to write the files with increasing sequence numbering. You can see additional options for numbering files in a drop down menu as soon as you enter % in the field.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Click Next.

10. Browse for the schema that represents the content we will write.

11. Click the Import Schema File button and navigate to

~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sche mas/internalorder.xsd to select and copy the schema file, and then select Order from the Type Chooser dialog.

3-12 Creating the Purchase Order Routing Service

Section 3.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

12. Click OK

13. Click Next and Finish to complete the File Adapter wizard and return to the

composite.

Section 3.6

Creating the Purchase Order Routing Service 3-13

3.7 Wiring the components and adding a transformation 1.

Next, wire the components to connect the service and reference to the mediator and complete the interface definitions. The wired components look like this.

2.

Double-click (right-click and select Edit) the routePO Mediator component to open the Mediator editor and create the mapping between the inbound PO and the internal order format that you use to log to the file.

3.

Click the icon to the right of the Transform Using field to display the Request Transformation Map window.

4.

Choose to Create New Mapper File with the default name.

3-14 Creating the Purchase Order Routing Service

Section 3.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 3.7

5.

Drag a wire from Purchase Order on the source side to Order on the target side.

6.

You are prompted for auto-mapping preferences:

Creating the Purchase Order Routing Service 3-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

To help in the mapping, you are going to leverage a dictionary created by the business analysts and that lists common synonyms in use across your data objects (e.g., “qty” is sometimes used instead of “quantity”, some departments use “ID” instead of “orderId”, etc.). 7.

Uncheck Match Elements Considering their Ancestor Names

8.

Click on Show Dictionaries.

9.

Click Add.

10. Browse to and select

/home/oracle/SOA11gFoundation/SOA11gFoundation/po/schemas/p o2internalorders-dictionary.xml. 11. Click Open

3-16 Creating the Purchase Order Routing Service

Section 3.7

12. Click OK.

As you can see in the mapper, the dictionary has helped match pairs of fields like as CustID to customerId and productName to prodName. Note that even without a dictionary, the auto-mapping feature will be able to identify and automatically take care of many of these fields, but a dictionary, customized to your company helps improve its accuracy. The resulting mapping looks like this:

Section 3.7

Creating the Purchase Order Routing Service 3-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

13. Save and close both the mapping and the Mediator editor to return to the

composite. 14. At this point, you have a fully-functional Mediator-based composite application

that can be deployed and tested. In later chapters, you will add more components to it.

3.8 Deploying the application Deploy the application in the same way as before. Read Appendix A Deploying and Running a Composite Application to refresh your memory on how to deploy if you need to. Remember, if you are prompted to login, the Username is weblogic and the Password is welcome1.

3.9 Testing the application Test your new application using the instructions here. Read Appendix A Deploying and Running a Composite Application for more details. 1.

After you have deployed your composite, open Enterprise Manager at the following link: http://localhost:7001/em (or use the Enterprise Manager bookmark entry at the top of the browser window).

2.

Click on POProcessing (under SOA/soa-infra) and the Test button to test your service.

3-18 Creating the Purchase Order Routing Service

Section 3.8

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Enter a small order by doing one of the following:



Type the values into in to the HTML form OR



Click XML View in the Input Arguments section so you can paste in the XML payload. This is the recommended way. Open the following file in a text editor like gedit: gedit ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/i nput/po-small-Headsetx1.xml Copy the entire contents and paste them into the large text field in Input Arguments area, replacing the blank xml form that is there:

4.

Section 3.9

Click Test Web Service.

Creating the Purchase Order Routing Service 3-19

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

The Test Result screen won't have any response because this is a one-way invocation with no reply or callback.

5.

You can view the Flow Trace by selecting Launch Message Flow Trace.

In addition, the call to the File Adapter service will have resulted in a new file in /home/oracle/tmp, called order_n.txt, where n is a sequence number like 1, 2, 3, etc. You can open that file with a text editor like gedit and examine it. Notice how field names have been translated by the mapping and are different from the input xml.

3-20 Creating the Purchase Order Routing Service

Section 3.9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.10 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Section 3.3: Creating a new application



Application Name: POProcessing



Directory: default directory



Project Name: POProcessing



Project Technologies: SOA



Empty Composite

Section 3.4: Adding the service interface



Service: receivePO



Type: Service



WSDL based on: po.xsd



Request: PurchaseOrder

Section 3.5: Adding the routing component



Mediator: routePO



Define Interface Later

Section 3.6: Adding the File Adapter



File Adapter: WriteApprovalResults



Directory for Outgoing Files: /home/oracle/tmp



File Naming Convention: order_%SEQ%.txt



Schema file: /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sc hemas/internalorder.xsd



Schema: Order

Section 3.7: Wiring the components and adding a transformation

Section 3.10



Wire: service to mediator to adapter



Mediator transform: Map Purchase Order to Order

Creating the Purchase Order Routing Service 3-21

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



In Auto-complete: Uncheck Match Elements Considering their Ancestor



In Auto-complete: Add Dictionary



Dictionary: /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sc hemas/po2internalorders-dictionary.xml

The application is completed. Continue with Section 3.8 above to deploy and test your application.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3-22 Creating the Purchase Order Routing Service

Section 3.10

4

4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8

BPEL Orchestration

Introduction .................................................................................................................................................... 1 Designing the flow ......................................................................................................................................... 1 Invoking the CreditCardStatus service ....................................................................................................... 2 Designing the BPEL approval process ........................................................................................................ 5 Modifying the Mediator component ..........................................................................................................14 Deploying the application ...........................................................................................................................20 Testing the application .................................................................................................................................20 Operations and naming ...............................................................................................................................24

4.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch4-BPEL. To run this solution, you must first complete Chapter 1 to set up the application. When receiving large orders (greater than $1000) we want to be more cautious and:



Validate the customer's credit card



Automatically accept or reject the order based on the credit card status

The tool for orchestrating these interactions is the BPEL process manager. The overall flow of the application uses the credit validation service and the purchase order processing service created earlier. Once completed, your POProcessing composite will look like this:

4.2 Designing the flow We will modify POProcessing with the changes outlined above. We’ll start by creating a reference to the service you created in chapter 2, the credit card validation

Section 4.1

BPEL Orchestration 4-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

service, using SOAP. Then, we’ll create the BPEL process to orchestrate the call to the credit card validation service and, based on the returned value, set the return status on the order. Finally, we’ll wire the BPEL process to the Mediator and add a routing rule so that it is called only when the order total is over $1000.

4.3 Invoking the CreditCardStatus service 1.

If it is not already open, open your POProcessing application in JDeveloper. Make sure there are no other files open. Then, open composite.xml for POProcessing. Closing all composite.xml files first eliminates any possible confusion as every composite has a composite.xml file.

2.

Start your server and make sure your credit card validation service is running there. See Appendix A for details about deploying.

3.

Drag-and-drop a Web Service activity into the External References swim lane.

4.

Set the following fields:



Name: getCreditCardStatus



WSDL File: The server must be running and the composite deployed that hosts the validationForCC service. Navigate to the service using the Resource Browser as follows. 1. Click the Find Existing WSDLs button next to the WSDL field 2. Select Resource Palette from the drop-down list at the top of the Resource Browser 3. Navigate to the validationForCC service 4. Select getStatusByCC operation and click OK

4-2 BPEL Orchestration

Section 4.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Alternatively, you can simply paste the URL to the WSDL into the field. The URL to the WSDL file can be obtained from the validationForCC test page in EM. Be sure to remove any version numbering. It will be something like this. http://localhost:8001/soainfra/services/CreditCardValidation/validationForCC/getStatusByCC?WSDL



5.

Section 4.3

Port Type: Once you have the WSDL URL, press the Tab key to move to the next field. The Port Type will be updated automatically based on the WSDL.

Click OK. Your getCreditCardStatus external reference appears in the composite diagram.

BPEL Orchestration 4-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Now, we’ll create a BPEL process to do orchestration for large order processing. The input and output to the BPEL process is in the internal order format of the purchase order. 6.

Drag-and-drop a BPEL Process component onto the Components swim lane.

7.

In the Create BPEL Process dialog, specify the following settings:



Name: approveLargeOrder



Template: Asynchronous BPEL Process



Service Name: approveLargeOrder_client



Expose as a SOAP Service: Unchecked



Input: Click the magnifying glass icon, expand Project Schema Files > internalorder.xsd and select Order



Output: Use the Order type, like you did for Input above

The WSDL for this service is created automatically using this information. Note that the input and output types specified here go into the WSDL for this service.

4-4 BPEL Orchestration

Section 4.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.

Click OK.

9.

Wire the BPEL process to the getCreditCardStatus service. Wiring in the composite automatically creates a partner link reference inside the BPEL process.

4.4 Designing the BPEL approval process Next, you'll build a simple BPEL process that calls the external getCreditCardStatus service to determine if the card status is valid or not. 1.

Double-click (right-click and select Edit) the BPEL component to open the BPEL editor. Notice the getCreditCardStatus partnerlink already in the References swim lane because you wired it in the composite. The editors keep the references in sync between the BPEL process and composite.xml.

2.

Section 4.4

Drag-and-drop an Invoke activity from the Component Palette to an insertion point right under the receiveInput activity.

BPEL Orchestration 4-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Drag the wire from the Invoke activity to the getCreditCardStatus. This tells your BPEL process to invoke that service.

4.

In the Edit Invoke dialog that opens. Don’t be concerned about ‚Errors: 3‛ appearing at the top of the window. Specify the following to fix these ‚errors:‛



Name: invokeCCStatusService



Input Variable: Click the green plus icon and then click OK to create a new global variable, accepting the default name and type. The variable designated for the input will contain the data that will be sent to the service when it is invoked. It is automatically created with the correct type expected by the service.



4-6 BPEL Orchestration

Output Variable: Click the green plus icon and then click OK to create a new global variable, accepting the default name and type.

Section 4.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

This variable contains the data that will be returned by the service, or the output of the service. It is automatically created with the correct type.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Click OK.

6.

Your BPEL process looks like this so far:

7.

You have created the variables that will be used when interacting with the getCreditCardStatus service, but they haven't been populated. The output variable will be populated when the service returns a result, but you need to populate the input variable yourself. In BPEL, you use an Assign activity to assign data to a variable. In this case you want to assign the credit card number that was passed into the POProcessing service to the getCreditCardStatus service. Drag-and-drop an Assign activity immediately above your Invoke activity.

Section 4.4

BPEL Orchestration 4-7

8.

Double-click (right-click and select Edit) the Assign activity to edit it.

9.

Click the General tab and change the name to assignCCNumber.

10. Click the Copy Operation tab. 11. Click the green plus icon and select Copy Operation to open the Create Copy

Operation dialog. Specify the following.



In the From (left) side, select Variables > Process > Variables > inputVariable > payload > Order > creditCardInfo > cardNumber



In the To (right) side, select Variables > Process > Variables > invokeCCStatusService_execute_InputVariable > request > creditcardStatusRequest > CCNumber

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

12. Click OK. 13. Back in the Assign dialog, add a second copy operation by click the green plus

icon and selecting Copy Operation, and specify the following.



In the From (left) side, select Variables > Process > Variables > inputVariable > payload > Order



In the To (right) side, select Variables > Process > Variables > outputVariable > payload > Order

You are doing this because the BPEL process returns outputVariable when it finishes. You will return the input data, as well as some updates which will be made later in the BPEL process.

4-8 BPEL Orchestration

Section 4.4

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

14. The Assign dialog now looks like this:

Section 4.4

Oracle University and Digora use only

End-2-end-105-PO-Processing

15. Click OK to return to the BPEL process.

BPEL Orchestration 4-9

16. Click the green check button in the upper left of the BPEL process to validate the

process. All the warnings (yellow flags) should go away. It now looks like this:

The input variable to getCreditCardStatus is now populated. The Invoke activity will pass that data to the service. The next step is to process the return data from the service, the output. The returned value can be VALID or INVALID. You want a Switch statement so you can do something different for each case. 17. Drag-and-drop a Switch activity right underneath invokeCCStatusService. 18. Double-click the name (Switch_1) of the Switch underneath the icon and rename

it to EvalulateCCStatus. Note: You can also double-click the Switch icon and change the name in the subsequent dialog, but if you double-click the text itself you can change the name in-place. 19. Expand the Switch by clicking the small plus icon next to it. 20. Click the View Condition Expression button to open the Condition Expression

window.

4-10 BPEL Orchestration

Section 4.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

21. Click the XPath Expression Builder button in the upper-right corner of the

Condition Expression window.

22. In the BPEL Variables field, expand Variables > Process > Variables >

invokeCCStatusService_execute_OutputVariable > reply and select creditcardStatus. 23. Click the Insert Into Expression button (it's the wide button under the

Expression field). 24. Put your cursor in the Expression field (wide button above the BPEL Variables

area) and at the end, and add: = 'VALID'

Section 4.4

BPEL Orchestration 4-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

25. Click OK. This specifies that the right-side branch of the Switch (the case

portion) is to be followed if the value of the credit card status is ‚VALID.‛ If the value is not ‚VALID‛, the otherwise branch is be followed. 26. Click outside the Condition Expression pop-up window to close it.

If that condition is true, then BPEL will execute any activities in the part of the switch. If not, any activities in the section will be executed. 27. Drag-and-drop an Assign activity into the section of the Switch.

28. Double-click the name of the new and rename it to assignApproval.

4-12 BPEL Orchestration

Section 4.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

29. Double-click the Assign icon to open the Assign dialog. 30. Click the green plus icon and add a new Copy Operation. 31. In the From section, change the Type drop-down list to Expression. 32. In the Expression field, type: 'approved' (with single quotes) 33. In the To section, select Variables > Process > Variables > outputVariable >

payload > Order > status.

34. Click OK. 35. Drag-and-drop an Assign activity into the section of the Switch. 36. Rename it to assignInvalidCC. 37. In the same way you just did above, assign the value 'invalidCreditCard' to the

status field of the outputVariable variable. 38. At the top of BPEL designer, click the green check mark to validate your process.

Any yellow flags you had should disappear and you should not have any warning messages.

Section 4.4

BPEL Orchestration 4-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

39. Save the BPEL process and close the window to return to the composite.

4.5 Modifying the Mediator component 1.

Wire the Mediator to the BPEL process.

2.

Your composite now looks like this:

3.

Now, the Mediator is routing requests to both the WriteApprovalResults service and the approveLargeOrder BPEL process. Sometimes, this is what you want a Mediator service to do, but in this case a new order should either be automatically approved or have to be approved by going through the approveLargeOrder process. If you recall, orders under $1,000 should be approved automatically while orders greater than or equal to $1,000 need to go through an approval process. The

4-14 BPEL Orchestration

Section 4.5

Mediator is capable of providing a content-based routing service to enable this kind of processing. Double-click the routePO Mediator component to open the Mediator editor. 4.

Click on the filter icon, called Invoke Expression Builder (which looks like a funnel) for the WriteApprovalResults::Write request operation.

5.

In the Expression Builder dialog, build up the following expression. Don’t copy this text into your expression. Instead, use the Variables frame to select the variables: ($in.request/inp1:PurchaseOrder/inp1:price * $in.request/inp1:PurchaseOrder/inp1:quantity) < 1000 Note: The namespaces (inp1) may be different for you. Hint: Expand the nodes in the Variables section to find the field you want and either double-click or press the Insert Into Expression button to add them to the expression.

Section 4.5

BPEL Orchestration 4-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

Click OK.

7.

Similarly, click the filter icon for the request invocation of approveLargeOrder/client::process

8.

Add the following expression:

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

($in.request/inp1:PurchaseOrder/inp1:price * $in.request/inp1:PurchaseOrder/inp1:quantity) >= 1000

4-16 BPEL Orchestration

Section 4.5

9.

Click OK.

10. You also need to set the callback of the asynchronous BPEL process to call the file

adapter service so that in the case of the large order processing, the order is still written to a file for the fulfillment archive. Click the cog icon next to the Target Operation field in the callback section. 11. In the Target Type dialog, click the Service button.

12. In the Target Services dialog, select POProcessing > References >

WriteApprovalResults > Write.

13. Click OK.

Section 4.5

BPEL Orchestration 4-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

14. A transformation needs to be added for the operations. It's the same as the

transformation done earlier, but the namespaces are different so a new transformation will need to be created. Click the transformation icon in the request section:

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

15. Select Create New Mapper File and click OK. 16. Drag a wire from PurchaseOrder in the source to Order in target. 17. In the Auto Map Preferences dialog, simply click OK without changing

anything since you already added the dictionary earlier. The resulting transformation looks like this:

18. Save and close the mapper to return to the Mediator editor. 19. You must also add a transformation for the callback. Click the transformation

icon in the callback section.

4-18 BPEL Orchestration

Section 4.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

20. Select Create New Mapper File and click OK. 21. Drag a wire from Order in the source to Order in the target. 22. In the Auto Map Preferences dialog, click OK.

The resulting transformation looks like this:

23. Save and close the mapper. 24. Save and close the Mediator editor to return to the composite. 25. Choose File > Save All from the menu or the toolbar (two diskettes icon) just to

make sure everything is saved.

Section 4.5

BPEL Orchestration 4-19

4.6 Deploying the application Deploy the application in the same way as before using the Deploy command on the Project Menu. Read Appendix A Deploying and Running a Composite Application to refresh your memory on how to deploy if you need to. Since you already deployed POProcessing once before, you must either choose a new version number or select Overwrite any existing composite when deploying. If you do overwrite the previous composite, the existing instances for the version become stale and can no longer be viewed.

4.7 Testing the application 1.

After deploying, in the EM console, click on the POProcessing application (under SOA/soa-infra) and then click Test to open the Test page.

2.

In the Input Arguments section, click XML View.

3.

In the previous chapter you submitted a small order which created an order file directly. This time you'll create a large order which the Mediator will route to the BPEL approval process. Open the following file in a text editor: ~/SOA/SOA11gFoundationTutorial/SOA11gFoundtionTutorial/po/i nput/ po-large-iPodx30.txt Copy the entire contents and paste them into the large text field in the Input Arguments section:

4.

Click Test Web Service in the lower-right corner of the browser panel.

5.

As before, the Test Result screen won't have any response because this is a oneway invocation with no reply or callback. However a new order_n.txt file will have been created in ~/tmp. You can open it in a text editor and view the results (shown in Figure 1). Notice that the value of on line 8 has been set to approved.

4-20 BPEL Orchestration

Section 4.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Figure 1 Output from order_n.txt file

Section 4.7

6.

Click the Request tab in the browser to return to the request page.

7.

Re-run the application using the same input data, but this time change the credit card number to 4321-4321-4321-4321 which represents an invalid credit card.

8.

Click Test Web Service to run the application.

9.

Open the new order file in /home/oracle/tmp and notice what the status is this time. This is the result of the statement in your BPEL process.

BPEL Orchestration 4-21

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Click Launch Message Flow Trace to see the details of the message flow for this

instance of your composite. Alternatively, click on the application. In the Last 5 Instances section click on the most recent instance to see the execution flow.

Notice that the flow trace shows you the flow through both composites. You can see the composite instance value on the far right. 11. You can click the approveLargeOrder link to look at the BPEL process instance

and you can click the various activities to see their results.

4-22 BPEL Orchestration

Section 4.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

An interesting one to click is the getCreditCardStatus invoke payload. 12. When you click the getCreditCardStatus invoke payload, the synchronous

request-response call, you see both the input to the service (i.e., what you're passing to the service) and the output (i.e., what you're getting back from the service). In the screenshots, below, the input to the service is the credit card number 43214321-4321-4321 and the output returned is INVALID.

Section 4.7

BPEL Orchestration 4-23

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

13. Back in the main screen of the EM console, run the Test page again and this time

use the small order that you used in the previous chapter, which can be found in /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutor ial/po/input/po-small-Headsetx1.txt Note that the BPEL process does not get invoked and instead you only get a new order file generated in /home/oracle/tmp. You know it didn’t get invoked because the status is set to Initial in the order_n.txt file. Initial was the value passed in for status in the po-small-Headsetxt1.txt file.

4.8 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Invoking the CreditCardStatus service



Reference: getCreditCardStatus



WSDL using Resource Browser - Service: validationForCC > getStatusByCC

Designing the BPEL approval process



Name: approveLargeOrder



Template: Asynchronous BPEL Process



Service Name: approveLargeOrder_client



Expose as a SOAP Service: Unchecked



Input: internalorder.xsd - Order



Output: internalorder.xsd - Order



Wire the BPEL process to the getCreditCardStatus service

4-24 BPEL Orchestration

Section 4.8

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



In BPEL Editor

-

Invoke Name: invokeCCStatusService

-

Wire: Invoke to getCreditCardStatus

-

Input Variable: default

-

OutputVariable: default

-

Assign before Invoke: assignCCNumber Copy 1 From: inputVariable > payload > Order > creditCardInfo > cardNumber To: invokeCCStatusService_execute_InputVariable > request > creditcardStatusRequest > CCNumber Copy 2 From: inputVariable > payload > Order To: outputVariable > payload > Order

-

Switch after Invoke: EvalulateCCStatus

-

Case Expression: bpws:getVariableData('invokeCCStatusService_execute_OutputVariable' ,'reply','/ns3:creditcardStatus') = 'VALID'

-

Case Assign: assignApproval Copy From: ‘approved’ To: outputVariable > payload > Order > status

-

Otherwise Assign: assignInvalidCC Copy From: ‘invalidCreditCard’ To: outputVariable > payload > Order > status

Modifying the Mediator component



Wire the Mediator to the BPEL process



Filter to Write: ($in.request/inp1:PurchaseOrder/inp1:price * $in.request/inp1:PurchaseOrder/inp1:quantity) < 1000



Filter to approveLargeOrder: ($in.request/inp1:PurchaseOrder/inp1:price * $in.request/inp1:PurchaseOrder/inp1:quantity) >= 1000



Callback Target Service: POProcessing > References > WriteApprovalResults > Write



Request Map from PurchaseOrder to Order



Callback Map from Order to Order

The application is completed. Continue with Section 4.6 above to deploy and test your application.

Section 4.8

BPEL Orchestration 4-25

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Adding Human Workflow

5.1 5.2 5.3 5.4 5.5 5.6 5.7

Introduction .................................................................................................................................................... 1 Designing the flow ......................................................................................................................................... 1 Adding a Human Task to the composite .................................................................................................... 2 Calling the Human Task from BPEL ........................................................................................................... 5 Creating the Task form for task details ......................................................................................................10 Deploying and Testing the application ......................................................................................................15 Operations and naming ...............................................................................................................................18

5.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch5-HW. To run this solution, you must first complete Chapter 1 to set up the application. In this next iteration of the application, you will add a Human Task to the composite in order to review large orders manually. Once completed, your POProcessing composite will look like this:

Designing the flow To review large orders manually, you add the Human Task to the BPEL process after the credit card has been validated and only for VALID cards. You also create the task form as a separate project in the application to be used at runtime with the worklist application.

Section 5.1

Adding Human Workflow 0-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Adding a Human Task to the composite 1.

In JDeveloper, drag-and-drop a Human Task component onto the composite.

2.

Specify the following:

3.



Name: ManualPOApproval



Namespace: Leave as default



Create Composite Service with SOAP Bindings: Unchecked

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Click OK.

0-2 Adding Human Workflow

Section 0

4.

Wire the BPEL process to the Human Task.

5.

Double-click (right-click and select Edit) the Human Task to open the Task Definition editor.

6.

Specify the following settings:



Title: Using the expression builder button at the right of the Title data entry area, enter ‘Approve Order’ and click OK. You see entered as the value in the data entry area.



Description: Manual approval task for large orders



Parameters: Order Use the green plus sign to open the Add Task Parameter dialog. Select Element and then browse for the Order element in internalorder.xsd.

Section 0



Editable via worklist: Checked (this is optional and only so that you can see the functionality as it doesn’t really make sense for this application)



Click OK

Adding Human Workflow 0-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

In the Assignment and Routing Policy section, double-click the box in the diagram.

8.

In the Add Participant Type dialog, specify the following:



Type: Single



Label: Large Order Approver

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9.

Use the green plus sign next to Participant Names to Add user

10. Set the Identification Type to User (already set) 11. Set Data Type By Name (already set) 12. In the Value Field enter: weblogic (no quotes)

Normally you would browse for users set in the server, however, there have not been users set yet. To browse for users, you must create a server connection to the SOA Managed server and, when you test that connection, some protocols will fail. However, you will be able to browse for users using it. 13. Click OK

0-4 Adding Human Workflow

Section 0

14. Save and close the Task Definition editor. Return to the composite.

Calling the Human Task from BPEL

Section 0

1.

Double-click the approveLargeOrder BPEL component to open the BPEL designer.

2.

Drag a Human Task into the branch of the , underneath the assignApproval activity (you will be moving this assign activity shortly).

3.

The Create Human Task dialog opens. Select ManualPOApproval from the Task Definition drop-down list.

4.

For Task Title, enter: Approve Order.

Adding Human Workflow 0-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Select the BPEL variable to pass the input parameter by clicking the […] button on the right of Order.

6.

Select Variables > Process > Variables > outputVariable > payload > Order. outputVariable has all of our information collected so far.

7.

Click OK.

8.

Click OK.

9.

You will have two new activities in your BPEL process: a Human Task and a Switch activity. The Human Task handles getting the approval (or rejection)

0-6 Adding Human Workflow

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 0

from a user of the work list application. The Switch activity can then be used to evaluate the results from the Human Task, for example, what to do if it's approved or if it's rejected. You just configured the Human Task, so the next step is to take appropriate actions in the Switch. Click the plus icon next to the Switch to expand it.

10. Notice the three outcomes for which this Human Task was configured:

APPROVE; REJECT; or EXPIRED, STALE, WITHDRAWN, or ERRORED. You will set the status for each of those cases. The approved case was already done earlier, so you can reuse that. Drag the assignApproval Assign activity underneath the CopyPayloadFromTask Assign activity in the APPROVE branch of the .

Section 0

Adding Human Workflow 0-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

11. Double-click (right-click and select Edit) the CopyPayloadFromTask Assign

activity in the REJECT branch. 12. Click the green plus icon and add a new Copy Operation. 13. Change the Type on the From area to Expression and set the status field of the

outputVariable variable to 'rejected'.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

14. Click OK.

15. Click OK. 16. Now, for the third branch, double-click (right-click and select Edit) the

CopyPayloadFromTask activity in the EXPIRED, STALE, WITHDRAWN, or ERRORED branch.

0-8 Adding Human Workflow

Section 0

17. Click the green plus icon and add a new Copy Operation. 18. Set the status field of the outputVariable variable to 'expired'.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

19. Click OK.

20. Click OK.

Section 0

Adding Human Workflow 0-9

The activity now looks like the following figure. Note that the APPROVE branch could have been done the same way as the other two, but in this case there are two separate activities. The end result is the same.

21. Save the BPEL process.

Creating the Task form for task details The Task data entry/display is an ADF form that is created in a separate project. You create a JSF project to manage the task form and point it to the task file you create in your composite. Creating a form from a Human Task definition is quick and easy. Simply accept the defaults for the different steps or customize as desired. A default form layout is created automatically. You have the option to edit this as desired. 1.

From the Application Menu, select New Project

2.

Select General in the Categories column and Generic Project under Items.

0-10 Adding Human Workflow

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Click OK

4.

Enter the project name: ApproveTaskDetails

5.

Click Finish

6.

Right-click on the new project (ApproveTaskDetails) and select New

Adding Human Workflow 0-11

7.

In the New Gallery, expand the Web Tier category and select JSF. Under Items, select ADF Task Flow Based on Human Task. Then, click OK.

8.

In the SOA Resource Browser dialog, browse to the ManualPOApproval.task file you created in the POProcessing project. Select it. This file is in the POProcessing folder.

9.

Click OK.

10. In the Create Task Flow dialog, accept all defaults and click OK.

0-12 Adding Human Workflow

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

11. The task details page is initialized and all of the artifacts needed for the form are

added to your new project.

12. Double-click on the taskDetails1.jpsx icon in the Task Flow view to finish

creating the task flow.

13. In the Create JSF Page dialog, accept all defaults and click OK.

Section 0

Adding Human Workflow 0-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

After some processing, the empty task flow page is opened. You will drag the task definition to this page to create all of the elements of the Order payload that you specified as the task payload when you created the task in the composite project. 14. Locate the Task definition in the Data Controls section of the Application

Navigator as shown in the figure below.

15. Drag the Task to the empty task flow page and drop it anywhere. 16. In the menu that opens, select Human Task -> Complete Task with Payload

0-14 Adding Human Workflow

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

17. In the dialog, Edit Action Binding, accept all defaults and click OK. Click OK

again to finish creating the task form. 18. Wait as processing occurs. The completed page layout will appear in the

taskDetails1.jspx window. Then, Save All and close all task windows that are open. In the Application Navigator pane, you see lots of files listed in the new task form project. Scroll the pane to the top and left and close the folders for the project to clean up the navigation view and allow you to see your composite project again.

Deploying and Testing the application 1.

Deploy the POProcessing composite from its project menu. Enter a new version number or select the checkbox to overwrite the existing version. Read Appendix A if you need more details about how to deploy and test your composite.

2.

Next, we’ll deploy the ApproveTaskDetails task form project by selecting Deploy from the Application menu in the toolbar. Task forms are deployed using the Application menu, not the Project menu. You can find the Application menu in the toolbar or you can right-click on the application name to bring up the menu or you can click the drop down menu icon to the right of the application name to open the application menu. Read Appendix A for more details about how to deploy your task form.

3.

Section 0

If prompted in the Deployment Configuration dialog, set the managed server soa_server1.

Adding Human Workflow 0-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click OK. If you chose to deploy the task form project from its project menu, you will see an error message and deployment will not complete. You must deploy task forms from the Application menu in the toolbar. Go back to step 2.

5.

Once deployed, open the EM console to test the application using the input for a large order as you did in the previous chapter. This will create a new order that's over $1,000. Copy the input data into the XML View in the Test page from: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/inpu t/po-large-iPodx30.txt

6.

As usual, the Response tab won't show any results as this is a one-way invocation with no reply or callback. Notice, however, that a new order file was not created in /home/oracle/tmp. That's because the application hasn't completed running yet. To see what's going on, you need to look at the instance audit trail.

7.

Click Launch Message Flow Trace to see the details of the message flow for this instance of your composite. Alternatively, click the latest instance from the composite page. You’ll notice the status for approveLargeOrder and ManualPOApproval are both still ‚Running.‛ They are waiting for the human task to be processed.

8.

Now it is time to "change hats" and log on to the worklist application as a customer service representative to approve the task. Using your browser, open http://localhost:7001/integration/worklistapp or click the Worklist Application bookmark.

9.

Logon using the following credentials:



Username: weblogic

0-16 Adding Human Workflow

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



Password: welcome1

The worklist application is an out-of-the-box application where users can view and manage their tasks. 10. Click on the most recent task row to highlight it.

Selecting the task opens it in the lower frame of the worklist application. The first time the task is opened there will be a delay while the form is compiled and loaded.

11. When the form opens, you can see the task details and the different options.

Select Reject or Approve as desired. This will submit the task and notify the BPEL process it can continue. If you have edited the task data, using the buttons will also save the data before submitting. If you use the Actions menu to submit the task, you must save manually first. 12. Return to the task flow in the Enterprise Manager console. If you still have it

open you can just refresh the page. By clicking the cycle icon in the upper-right corner of the window. Notice that all steps are now ‚Complete.‛

13. You will also have a new order file in /home/oracle/tmp.

Section 0

Adding Human Workflow 0-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Adding a Human Task to the composite



Name: ManualPOApproval



Namespace: Leave as default



Expose as Composite Service: Unchecked



Wire: BPEL to task



Title: (enter ‘Approve Order’ using the expression builder)



Description: Manual approval task for large orders



Parameters: internalorder.xsd > Order



Editable via worklist: Checked



Participant Type dialog, specify the following:

-

Type: Single , Label: Large Order Approver, User: weblogic

Calling the Human Task from BPEL



In case statement, after assignApproval, Human Task: ManualPOApproval



Task Parameter: Variables > Process > Variables > outputVariable > payload > Order



Move assignApproved to APPROVE branch after CopyPayloadFromTask



CopyPayloadFromTask Assign REJECT branch



-

Copy from: 'rejected'

-

To: outputVariable > payload > Order > status

CopyPayloadFromTask Assign Otherwise branch

-

Copy from: ‘expired’

-

To: outputVariable > payload > Order > status

Creating the Task form for task details



Right-click human task, select Auto-generate task form



Project Name: ApproveTaskDetails OR



Application menu > New Project, generic project

0-18 Adding Human Workflow

Section 0

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



Project Name: ApproveTaskDetails



Project menu > New



JSF > ADF Task Flow Based on Human Task

-

POProcessing> POProcessing> ManualPOApproval.task



Double-click taskDetails1.jspx icon in Task Flow view, click OK



Open Data Controls > getTaskDetails > Return > Task



-

Drag Task to the open task details page

-

select Human Task -> Complete Task with Payload

Click OK on remaining dialogs, accepting defaults.

The application is completed. Continue with Section 5.6 above to deploy and test your application.

Section 0

Adding Human Workflow 0-19

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6

6.1 6.2 6.3 6.1

Modifying the Mediator

Introduction .................................................................................................................................................... 1 Modifying the application ............................................................................................................................ 2 Deploying and testing the application ........................................................................................................ 4 Operations and naming ................................................................................................................................ 5

6.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch6-update. To run this solution, you must first complete Chapter 1 to set up the application. The application is almost complete, but there is an issue. For orders under $1,000, the order is routed directly to the file adapter via the Mediator. For orders over $1,000, the mediator routes the request to the BPEL process for approval before sending it to the file adapter to be written. Look at Figure 1 and Figure 2. They show the output for a small order and large respectively. There is an important difference, do you see it? Figure 1 Output file for a small order

Section 6.1

Modifying the Mediator 6-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Figure 2 Output file for a large order

In the case of the large order, the BPEL process sets the status. In this case, the status is approved. However, in the case of small orders that get routed only through the Mediator, the status is not updated and it still set at initial. This creates inconsistent data. The application should be modified such that small orders are always approved. Where do you think this change should be made? Follow the next steps to find out.

6.2 Modifying the application 1.

In the POProcessing composite.xml, double-click the routePO Mediator component to open it.

2.

Modify the existing transformation for the WriteApprovalResults::Write operation by clicking the transformation button to the right of the Transform Using field.

6-2 Modifying the Mediator

Section 6.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 6.2

3.

Ensure that Use Existing Mapper File is selected, and click the edit button represented by the pencil icon. This will open the existing transformation.

4.

Click the mapping for status to highlight it.

5.

Press the Delete key on your keyboard to remove it.

6.

Right-click status on the target side (right side) and select Set Text and then Enter Text…

7.

Enter approved in the Text field. Modifying the Mediator 6-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.

Click OK. The status field has a visual cue to let you know a test value has been assigned.

9.

Save and close the mapper.

10. Save and close the Mediator editor.

6.3 Deploying and testing the application 1.

Deploy the POProcessing composite as you have before. Don’t forget to select to “Overwrite any existing composites …” as you deploy.

2.

In Enterprise Manager, test the application using the small order input (from ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/inpu t/po-small-Headsetx1.xml).

3.

Open the resulting output order file in ~/tmp and see that the status is approved.

6-4 Modifying the Mediator

Section 6.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.1 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Modifying the application



Edit Transform: PurchaseOrder_To_Order.xsl



Remove wire: status



Set Text on target: status



Value: approved

The application is completed. Continue with Section 6.3 above to deploy and test your application.

Section 6.1

Modifying the Mediator 6-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7

Adding Business Rules

7.1 Introduction .................................................................................................................................................... 1 7.2 Designing the flow ......................................................................................................................................... 1 7.3 Adding a Business Rule to POProcessing .................................................................................................. 2 7.4 Deploying POProcessing composite ..........................................................................................................14 7.5 Running the application...............................................................................................................................15 7.5.1 Additional Test Cases ...........................................................................................................................16 7.1 Operations and naming ...............................................................................................................................16

7.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch7-Rules. To run this solution, you must first complete Chapter 1 to set up the application. In this chapter, you will add a business rule to the composite to make the decision on whether the human task is required for manual approval or not. When you added the human task, the BPEL process started calling it for orders > $1000. Now, the new business rule will determine whether or not the human task is required. When this chapter is completed, the composite will look like this.

7.2 Designing the flow The business rule uses the order total to determine whether or not manual approval is required. Orders over $5000 require manual approval otherwise, the order is

7.1.1.1

Section 7.1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

approved automatically. The BPEL process only sends to the business rule orders that have already had the credit card validated.

7.3 Adding a Business Rule to POProcessing First you’ll add the business rule component to the composite and then, you will invoke the rule from the BPEL process. 1.

Add the Business Rule component to the composite by dragging it to the Components section.

2.

In the Create Business Rules dialog enter ManualApproval for the dictionary Name.

3.

Now, we’ll set the input and output schema. Selecting Input from the green plus-sign drop down opens the Type Chooser for identifying the schema. Select the Import Schema File button in the upper-right corner to import a schema and then browse to the schema location: ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/schemas/OrderBookingDiscount.xsd

Adding Business Rules 7-2

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click OK to dismiss the Import Schema File window and select OK to close the Localize Files window.

5.

In the Type Chooser, select price for the input schema type.

6.

Click OK.

7.

Repeat the same steps to identify the output schema. Under the green plus sign menu, select Output. This time you won’t need to import the schema type. Just select the type discountandshipping.

7.1.1.1

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Once the dialog is complete, click OK to close it. You’ll see the ManualApproval rule component added to the composite.

Adding Business Rules 7-4

Section 7.3

9.

Double-click (right-click and select Edit) the new rules component to open the rule editor. RuleSet_1 is selected.

10. Click the green plus sign to add a rule template.

11. Select and then, select in the IF statement. Next, select

the price.price object.

12. Complete the test for >= 5000. Press Enter to enter the value and add the THEN

clause to create the return result. 13. Select and select assert new. Select and select

discountandshipping

7.1.1.1

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



Select the box and a dialog comes up to set the property values. Set the values as shown. We are not using discount or shipping in this composite application so set those values to 0 (use Enter to enter the value). For orders $5000 or more, set the approval required to true. Also set the price value to the input price. approvalRequired = true discount = 0 price = price.price shipping = 0

14. Repeat the process to add a second rule for orders under $5000. In this case,

approval is not required.

Adding Business Rules 7-6

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

15. Save and close the ManualApproval.rules file you were just editing. 16. Double-click the approveLargeOrder BPEL component in the composite to open

the BPEL process. You will be adding a rule activity just before the existing human task. But first, let’s first create a variable to store the output from the ruleset. 17. In the Structure palette, open Variables/Process and select the Variables node.

If the Structure palette is not open, select it from the View menu.

18. Select the green plus sign icon to add a variable named approvalRequired of type

discountandshipping. To select the type, click on the Element radio button and browse to orderBookingDiscount.xsd/discountandshipping.

7.1.1.1

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

19. Click OK to dismiss the Create Variable dialog. 20. Now drag a Business Rule from the palette onto the BPEL process just before

the ManualPOApproval_1 human task within the case block of the switch activity. The Business Rule dialog opens. Set the Name to ApprovalRule and select the ManualApproval Dictionary you just created in the composite.

Adding Business Rules 7-8

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

21. Now, let’s focus on the input and output facts. The input fact will be the total

price. Create an expression using the expression builder to multiply the item price by the quantity. Start by selecting the Assign Input Facts tab and then clicking the green plus icon to display the Decision Fact Map. Build the expression as shown:

22. Click OK to dismiss the Decision Fact Map. 23. After the ruleset is evaluated, the output fact is returned. Start by selecting the

Assign Output Facts and clicking the green plus sign icon. Set the value of the output fact to the variable you just created. Make sure to select the whole payload to copy all the values over. However, we are really only interested in the approvalRequired value.

7.1.1.1

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

24. Click OK to close the Business Rule dialog. 25. Now, drag a Switch activity from the palette to right below the ApprovalRule

activity. Then, click the plus icon to the left of the switch to expand the case blocks.

26. Select Save All before continuing.

Adding Business Rules 7-10

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

You will be moving the human task and switch statement into the case block of this new Switch activity. Before you do that, we’ll drag a Sequence activity to keep the moved activities in the proper order. 27. Drag a Sequence activity from the palette into the case block. 28. Move the ManualPOApproval human task into the Sequence block for this

switch so that it only executes when the test case is true. 29. There was a Switch activity that followed the human task for processing the

results that set the status to approved or rejected. Move this into your new sequence block in the switch activity case statement as well.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

30. Select Save All before continuing. 31. Use the Expression Builder to set the test case expression in the case block. You

want to invoke the human task only when manual approval is required. This is the result from the ApprovalRule evaluation above. Start by clicking the expression editor icon in the upper-right corner of the case block. Build this expression: bpws:getVariableData('approvalRequired','/ns5:discountandsh ipping/ns5:approvalRequired') = ‘true’

7.1.1.1

Section 7.3

32. Next, add an Assign activity in the Otherwise block of your new Switch. Name

this new assign: AutoApproved. This assigns the status value ‚approved‛ for the case where the manual task is not required.

Adding Business Rules 7-12

Section 7.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

33. Save All your changes.

34. Your completed BPEL changes look like the illustration below:

7.1.1.1

Section 7.3

Oracle University and Digora use only

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Review the logic of the changes you made. Recall that when the credit card is valid, you ask the rule to tell you if manual approval is required. If manual approval is required, you call the human task service to take care of that and set the status based on the returned value. If manual approval isn’t required, you auto approve the order in the otherwise block. You have completed all changes and are ready to deploy. Continue with the next section.

7.4 Deploying POProcessing composite 35. In the same way as you did before, deploy your newly updated POProcessing.

When you see the Deployment Plan dialog, enter a new version or select the Overwrite Version checkbox and click OK.

Adding Business Rules 7-14

Section 7.4

7.5 Running the application 36. Once the application is deployed, you are ready to try running it. Open the EM

console at http://localhost:7001/em 37. Click on POProcessing and then the Test button to test your service. 38. Enter an extra large order ( >= 5000) by



Clicking XML View so you can paste in the XML payload. This is the recommended way. Open the following file in a text editor: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/i nput/po-xtralarge-HDTVx10.txt Copy the entire contents and paste them into the Input Arguments field in your browser, replacing the defaulted xml:

39. Click Test Web Service. 40. As you recall, the Response panel won't have any response because this is a

one-way invocation with no reply or callback. There is also no file written to the output directory. That's because the application hasn't completed running yet. To see what's going on, you need to look at the instance audit trail. 41. Click Launch Message Flow Trace to see the details of the message flow for this

instance of your composite. You’ll notice the status for approveLargeOrder and ManualPOApproval are both still running. They are waiting for the human task to be processed. 42. Login to the worklist application at

http://localhost:7001/integration/worklistapp (use the Worklist Application bookmark) with user weblogic/welcome1 and approve the task. 43. Return to the task flow in the EM console. If you still have it open, you can just

refresh the page (refresh cycle icon in the upper-right corner of the page). Notice that all steps are now complete.

7.1.1.1

Section 7.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.5.1 Additional Test Cases We have now used four test cases for your application depending on the input data value of the total price (price X quantity):



Under $1000 – auto approval without BPEL component involved



Invalid credit card – auto rejection using BPEL but no business rule and no human task components involved



1000 to under 5000 - auto approval using BPEL with business rules but no human task involvement



5000 and over – manual approval using BPEL including both the business rule and human task components

You just exercise the fourth test case above. Spend a few minutes and exercise the other three to make sure your BPEL process is working as expected. Here are the test cases you can use:



Under $1000 – po-small-Headsetx1.txt



Invalid credit card – po-large-iPodx30.txt but change the credit card number in Tree View to: 4321-4321-4321-4321



1000 to under 5000 – po-large-iPodx30.txt



5000 and over – po-xtralarge-HDTVx10.txt

7.1 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Adding a Business Rule to POProcessing



Composite Business Rule: ManualApproval

-

Input: OrderBookingDiscount.xsd > price

-

Output: OrderBookingDiscount.xsd > discountandshipping

Adding Business Rules 7-16

Section 7.1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



RuleSet_1: Rule 1: If price >= 5000 then assert new discountandshipping with approvalRequired = true.



RuleSet_1: Rule 2: If price < 5000 then assert new discountandshipping with approvalRequired = false.



BPEL variable: approvalRequired of type discountandshipping



Business Rule just before the Human Task



BusinessRule: ApprovalRule, ManualApproval

-

Input fact: price*quantity to price

-

Output fact: discountandshipping to approvalRequired > discountandshipping



Switch below Rule



Case expression: bpws:getVariableData('approvalRequired','/ns5:discountan dshipping/ns5:approvalRequired') = true()



Case: add Sequence, move Human Task and human task switch



Otherwise: Assign: AutoApproved

-

Copy From: ‘approved’

-

Copy To: outputvariable > status

The application is completed. Continue with Section 7.4 above to deploy and test your application.

7.1.1.1

Section 7.1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8

8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9

Adding Fulfillment

Introduction .................................................................................................................................................... 1 Designing the flow ......................................................................................................................................... 2 Add a BPEL Process and a Business Rule .................................................................................................. 2 Define the Business Rule ............................................................................................................................... 5 Define the BPEL Process ..............................................................................................................................10 Invoke FulfillmentProcess ...........................................................................................................................11 Deploying the application ...........................................................................................................................16 Testing the application .................................................................................................................................16 Operations and naming ...............................................................................................................................17

8.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundation/ SOA11gFoundation/po/solutions/ch8-DT. To run this solution, you must first complete Chapter 1 to set up the application. In this chapter you will add a BPEL process to the composite with a business rule using a decision table to make the decision of which fulfillment carrier to use for fulfilling the order. Orders under $1000 use USPS, orders from $1000 and under $5000 use UPS and orders over $5000 use FedEx. When finished, the composite will look like this:

Section 8.1

Adding Fulfillment 8-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.2 Designing the flow The business rule uses the order total to determine which fulfillment vendor to choose. Three order total ranges are used, which means there would be multiple IFTHEN clauses to create to cover all of the cases. Instead, you use a decision table to create the three values in the bucketset and create only three rules. The fulfillment process must be called whenever the order is approved. This is in the BPEL approveLargeOrder process, but it is also in the first case, in the routePO mediator when the order is under $1000 and is automatically approved.

8.3 Add a BPEL Process and a Business Rule You first add the BPEL process component to the composite and then you add the business rule. 1.

8-2 Adding Fulfillment

Add the BPEL process component to the composite by dragging it to the Components section. Complete the dialog as follows.

-

Name: FulfillmentProcess

-

Template: Asynchronous BPEL Process

-

Service Name: fulfillmentprocess _client

-

Expose as a SOAP Service: Unchecked

-

Input: Click the flashlight icon. In the Type Chooser dialog, click the Import Schema File button and import ~/SOA11gFoundation/SOA11gFoundation/po

Section 8.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

schemas/fulfillment.xsd in the same way as you have previously imported an xsd. Select Fulfillment as the input type.

-

Section 8.3

Output: Select CarrierSelection in fulfillment.xsd as the output type

2.

Click OK.

3.

Now, drag a business rule component to the Components section. Complete the dialog as follows.

-

Name: FulfillmentRules

-

Package: fulfillmentrules

-

Input: Fulfillment

-

Output: CarrierSelection

-

Advanced tab>Service Name: OracleRulesFulfillment

Adding Fulfillment 8-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click OK.

5.

Drag a wire from the new FulfillmentProcess BPEL component to the new FulfillmentRules rule.

6.

Drag another wire from ApproveLargeOrder BPEL component to the new FulfillmentProcess BPEL process.

8-4 Adding Fulfillment

Section 8.3

8.4 Define the Business Rule Now, you can define the business rule. You need a rule that will distinguish between the three carriers based on the order total. Rather than write out multiple exclusive if-then statements in the ruleset, you can do this more easily with a decision table. First, we’ll define the three ranges of the order total that you want to use for evaluation. Then, we’ll use those ranges in the decision table to determine the carrier. 7.

In the composite, double-click the FulfillmentRules business rules component to open the rule editor.

8.

Click Bucketsets in the left-side palette. Notice that one bucketset has already been created. In the fulfillment.xsd schema, CarrierValue is a restricted String type and is therefore represented as a Java enum. All imported Java enums are used to create a bucketset of their values. You use this bucketset to assign the return value, CarrierSelection.

9.

Section 8.4

As shown below, add a List of Ranges and then click edit to define the values in the new bucketset.

Adding Fulfillment 8-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Enter the Name as OrderTotal and Data Type as double. 11. Click the green plus icon (next to the red X) twice to add two buckets and edit

the values as follows.

-

Endpoint: 5000, Alias: xtralarge

-

Endpoint: 1000, Alias: large

-

Endpoint: -Infinity, Alias: small

12. Click OK. 13. Now, you have to associate this bucketset with the input fact. Click Facts and

select and edit FulfillmentType. 14. Set the value in the Bucketset column for total property to: OrderTotal by using

the drop-down list.

8-6 Adding Fulfillment

Section 8.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

15. Click OK. 16. Select CarrierSelection and click edit. You see the value carrier has already been

associated with the bucketset CarrierValue. All imported Java enums are automatically associated with properties of their type. 17. Click OK. 18. Now, you are ready to create the decision table. Click Ruleset_1 in the left-side

palette. Use the drop -down menu on the green plus icon to select Create Decision Table. 19. Click . Right-click and select Edit Condition.

Then, choose FulfillmentType.total:

Section 8.4

Adding Fulfillment 8-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

20. Click the cell under R1 and choose small – the range you created previously.

21. Select the menu for the green plus icon just above the rule and select Rule to

add a second rule. The R2 column appears. Click in the cell under R2 and set this rule name to large.

22. Add a third rule and set its name to xtralarge. These three rules, which are the

ranges defined earlier, are evaluated against the condition FulfillmentType.total.

8-8 Adding Fulfillment

Section 8.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

23. Now, let’s set the Actions for these three rules. Click and select

Assert New. Right-click the assert new ( text and select Edit. In the Action Editor window, select CarrierSelection 24. Select the checkbox for Parameterized. 25. Select the checkbox for Always Selected.

26. Click OK. 27. Now set the values. Select the cell for each of the three rules and set the carrier

value for each one: small=USPS, large=UPS, xtralarge=FED_EX

Section 8.4

Adding Fulfillment 8-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

28. That’s it! The decision table is complete. Save All and close the rule editor.

8.5 Define the BPEL Process Now, we’ll define the fulfillment BPEL process that will use this business rule. At first, this simply calls the business rule you just created. In the next chapter, you add additional functionality to send the fulfillment message. 29. Double-click FulfillmentProcess BPEL component to open the BPEL editor. 30. Drag a Business Rule activity to the process flow. Place it right after the

receiveInput activity. 31. In the Business Rule dialog, leave the default name and select the

FulfillmentRules from the Dictionary drop-down list. 32. In the Assign Input Facts tab, click the green plus icon to add an assignment to

map the BPEL inputvariable to the rule input fact.

8-10 Adding Fulfillment

Section 8.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

33. Click OK to close the Decision Fact Map. 34. In the Assign Output Facts tab, assign the output fact to outputvariable.

35. Click OK to dismiss the Decision Fact Map. 36. In the Business Rule dialog, click OK. Your new BusinessRule_1 appears in the

BPEL process. 37. Save All your work.

8.6 Invoke FulfillmentProcess Now, we’ll need to invoke your new fulfillment process. It should be called whenever you have an approved order. There are two places to call it: once in

Section 8.6

Adding Fulfillment 8-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

the approveLargeOrder BPEL process and once in the routePO mediator for small orders that are automatically approved. 38. You’ve already wired it to ApproveLargeOrder so let’s start there. In the

composite, double-click the approveLargeOrder BPEL component to open the BPEL editor. 39. Locate the switch branch for valid credit cards. Drag an Invoke at the end of

this branch inside the branch scope.

40. Wire the Invoke to the partnerLink for FulfillmentProcess which was added for

you when you wired the rule to the process earlier. You might want to maximize (right-click the tab and select Maximize) and change the Zoom level in order to better navigate the process model. 41. In the Edit Invoke dialog, set the Name to Invoke_Fulfillment and use the green

plus icon to create the input variable using the default values.

8-12 Adding Fulfillment

Section 8.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

42. Click OK and see that the Invoke_Fulfuillment is connected to the partner link. 43. Do you remember what input the FulfillmentProcess service is expecting? It is

the FulfillmentType which contains customer id, order id and order total. The easiest way to set this input value is to use a Transform. Drag a Transform activity just before the new Invoke_Fulfillment activity. 44. Edit the new transform. You will need to make sure your Zoom level is set to

100% in order to see the Transform window. Use the green plus icon to set the Source for the transformation to inputvariable and its Part to payload. Set the Target Variable to Invoke_Fulfillment_process_InputVariable with a Target Part of payload.

Section 8.6

Adding Fulfillment 8-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

45. Click the green plus icon next to the Mapper File to create the mapper file. 46. Perform mappings to copy the customer id and order id values. 47. For total, you have to multiply price and quantity so use a mathematical

function. First, drag the multiply function from the Mathematical Functions tab into the middle area. Then, drag the wires for price and qty values into the function. Finally, drag a wire from the function to total.

48. Save and close the transformation mapper.

Take a look at the process. It isn’t quite complete because there should be fulfillment only when the human task is approved. You need to add a switch statement to check for the approved status for both the auto-approved or human task approved cases. Once the switch has been added, we’ll rearrange things a bit so the Invoke_Fulfillment is executed after the human approves the task.

8-14 Adding Fulfillment

Section 8.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

49. Drag a Switch activity directly below the Invoke_Fulfillment. Name it

Switch_Fulfillment, and expand the switch to see its case and otherwise branches. 50. Since you are going to move both the Transform and the Invoke activities into

the case branch of the Switch, drag a Sequence activity block into the case branch to hold them. 51. Drag the Transform_1 and Invoke_Fulfillment activities into the Sequence

block within the case branch. 52. Use the View Condition Expression icon and XPath Expression Builder icon to

add the condition statement to the case block to check the status. It should look like this in the Expression Builder: bpws:getVariableData('outputVariable','payload','/ns2:Order/ns2:status') = 'approved' 53. Remove the otherwise branch because there is no action to take here. Just right-

click on the otherwise branch and select Delete. 54. The changes to the BPEL process are complete. Save All and return to the

composite. 55. Now, you need to invoke fulfillment from the mediator to take care of the case

when an order is auto-approved. So, double-click on routePO to open the mediator editor. 56. Select the green plus icon and choose static routing rule. 57. Select Service as the type and in the dialog, navigate to POProcessing > BPEL

Processes > FulfillmentProcess > Services > fulfillmentprocess_client > process. 58. Click OK. 59. A new routing rule is added to the bottom of the table. You want to call

fulfillment from here only in the auto-approval case so you need to set the filter to the same thing as in the first case, that is, for orders under 1000. Click the filter icon (the funnel) to open the Expression Builder and enter: ($in.request/inp1:PurchaseOrder/inp1:quantity * $in.request/inp1:PurchaseOrder/inp1:price) < 1000 60. Click OK to dismiss the Expression Builder. 61. Click the transform icon on the right (next to the Transform Using drop-down

menu) and create a transformation mapping, as youd did earlier, using the multiply function to set the value for total. 62. Save and close the transformation mapper.

The new routing rule is complete. You don’t need to set the callback because you are not interested in the return value here.

Section 8.6

Adding Fulfillment 8-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

63. Save and close the mediator routing rule editor.

You are all done! Now, you are ready to test.

8.7 Deploying the application Deploy the POProcessing in the same way as before using the Deploy command on the Project Menu. Don’t forget to elect to Overwrite any existing components. If you need to, read Appendix A Deploying and Running a Composite Application to refresh your memory on how to deploy.

8.8 Testing the application So far, the fulfillment process determines the delivery carrier but doesn’t really do anything with the information so you have to use the flow trace view in the EM console to see that everything is working correctly. 64. Open the Enterprise Manager console and click on POProcessing under

SOA/soa-infra. 65. Click Test. 66. Using the input files in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/input, run

three tests with small (po-small-Headsetx1.txt), large (po-large-iPodx30.txt) and extra large orders (po-xtralarge-HDTVx10.txt). 67. Click Launch Message Flow Trace to view the instance data. 68. For the extra large order, submit the approval task to complete the process. 69. Verify that the FulfillmentRules component returns USPS (small), UPS (large)

and FedEx (extra large) as the delivery carrier appropriately. 70. Submit a second extra large order and this time Reject the order approval.

Verify that Fulfillment is not called. 71. Submit an order with an invalid credit card (ccNumber: 4321-4321-4321-421)

and verify that Fulfillment is not called.

8-16 Adding Fulfillment

Section 8.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.9 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Add a BPEL Process and a Business Rule



BPEL Name: FulfillmentProcess



Template: Asynchronous BPEL Process



Service Name: fulfillmentprocess _client



Expose as a SOAP Service: Unchecked



Input: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/s chemas/fulfillment.xsd > Fulfillment



Output: CarrierSelection



Rule Name: FulfillmentRules



Package: fulfillmentrules



Input: Fulfillment



Output: CarrierSelection



Advanced tab>Service Name: OracleRulesFulfillment



Wire: FulfillmentProcess to FulfillmentRules



Wire ApproveLargeOrder to FulfillmentProcess

Define the Business Rule

Section 8.9



Bucketset: List of Ranges



Name: OrderTotal



Data Type: double.



Endpoint: 5000: Alias: xtralarge



Endpoint: 1000: Alias: large



Endpoint: -Infinity: Alias: small



Facts: FulfillmentType > Bucketset: total to OrderTotal



Ruleset_1: DecisionTable_1: Condition: FulfillmentType.total



R1: small, R2: large, R3: xtralarge



Actions > Assert New: CarrierSelection



Checkboxes: Parameterized, Always Selected

Adding Fulfillment 8-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



Values: small=USPS, large=UPS, xtralarge=FED_EX

Define the BPEL Process



FulfillmentProcess: Business Rule: FulfillmentRule, FulfillmentRules

-

Input fact: inputvariable>Fulfillement to Fulfillment

-

Output fact: outputvariable>CarrierSelection to CarrierSelection

Invoke FulfillmentProcess



BPEL: ApproveLargeOrder



Drag Invoke: into switch branch for valid credit cards



Wire Invoke: to FulfillmentProcess



Name Invoke_Fulfillment



Input variable: defaulted



Transform before Invoke: inputvariable to Invoke_Fulfillment_process_InputVariable



Wire: customer id and order id values



Multiply: price*quantity wired to total



Switch: Switch_Fulfillment below Invoke_Fulfillemnt



Case expression: outputVariable>status = 'approved'



Case: add Sequence, move Transform and Invoke



Otherwise: delete branch



Mediator. routePO



static routing rule > Service: FulfillmentProcess > fulfillmentprocess_client > process



Filter: orders < 1000



Transform: PurchaseOrder_To_Fulfillment.xsl

The application is completed. Continue with Section 8.7 above to deploy and test your application.

8-18 Adding Fulfillment

Section 8.9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9 9.1 9.2 9.3 9.4 9.5 9.6 9.7

Adding JMS to Fulfillment

Introduction .................................................................................................................................................... 1 Designing the flow ......................................................................................................................................... 2 Add the JMS adapters ................................................................................................................................... 2 Invoke the services from BPEL .................................................................................................................... 8 Deploying the application ...........................................................................................................................11 Testing the application .................................................................................................................................11 Operations and naming ...............................................................................................................................12

9.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch9-JMSAdapter. To run this solution, you must first complete Chapter 1 to set up the application. In this chapter you will send the fulfillment information to a JMS queue at the end of the fulfillment process. The delivery carrier was determined in Chapter 8 and you send a message to a queue depending on the carrier. To make this easier to test, however, just use the same queue configuration for all three carriers. When finished, the composite will look like this:

Section 9.1

Adding JMS to Fulfillment 9-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9.2 Designing the flow The way we left the fulfillment process in the last chapter was that it determined the carrier to be used, but it didn’t do anything with that decision. In this exercise, we’ll add the action: updating a JMS queue. To add the JMS messaging, we’ll add the three JMS services for USPS, UPS, and FedEx and then invoke the appropriate service from the BPEL process.

9.3 Add the JMS adapters If you didn’t do it at the outset of the lab exercises, you’ll first need to set up the JMS queue using the WebLogic console. You have to create a JMS destination queue, a JMS connection factory and also a JMS connection pool. Follow instructions in Chapter 1 if you haven’t already done so. Next, you’ll add a JMS adapter for each carrier. If you have your server running, the adapter wizard will be able to lookup the JMS destination queue. 1.

In JDeveloper, open the POProcessing composite.xml.

2.

Drag a JMS Adapter to the External References section of the composite.

3.

Click Next to advance the wizard. Then, name the service: JMS_USPS

9-2 Adding JMS to Fulfillment

Section 9.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section 9.3

4.

Click Next

5.

Select the OEMS service Oracle Weblogic JMS

6.

Click Next

7.

Select the Service Connection

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Adding JMS to Fulfillment 9-3

8.

Click Next

9.

For the Adapter Interface, select the radio button for defining this later.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Click Next

11. For the Operation, select Produce Message

9-4 Adding JMS to Fulfillment

Section 9.3

12. Click Next 13. For the Produce Operation Parameters, click Browse to lookup the JMS

destination queue and select demoFulfillmentQueue.

14. Click OK

Section 9.3

Adding JMS to Fulfillment 9-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

15. Enter the JNDI name associated with the JMS Adapter: eis/Queue/demo

16. Click Next 17. For the message schema, use the magnifying glass to browse to fulfillment.xsd

and select the Fulfillment element.

18. Click Next and then click Finish. The JMS_USPS external reference is added to

your composite.

9-6 Adding JMS to Fulfillment

Section 9.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

The first adapter service is complete. 19. Repeat the steps you just used for JMS_USPS to create two more services,

JMS_UPS and JMS_FedEx. You’ll end up with a total of three JMS-related external references displaying in your composite. 20. From FulfillmentProcess BPEL component, drag a wire to each of the three JMS

services. 21. Save All your work.

These services represent the three carriers and the message that is sent is the order information for fulfillment. As mentioned earlier, normally the three carriers would all have individual destination queues. However, for easier testing, just use one queue for all of them. Your composite now looks like this:

Section 9.3

Adding JMS to Fulfillment 9-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9.4 Invoke the services from BPEL Next, we’ll go into the BPEL process and see that we invoke the three services according to the value of carrier returned from the decision service. 22. Open the FulfillmentProcess BPEL process and drag a Switch activity below the

BusinessRule_1 activity. 23. Expand the Switch and use the Add Switch Case icon (shown below) to add

two more case branches:

24. Double-click on the first bar and set the Name to USPS. 25. Select the Expression Builder icon to set the condition expression for the first

case. Using the Insert Into Expression button, build the expression as follows bpws:getVariableData('outputVariable','payload','/ns2:CarrierSelection/ns2:carrier') = 'USPS'

9-8 Adding JMS to Fulfillment

Section 9.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

26. Click OK. Repeat for the next two cases, setting the condition for ‘UPS’ and

‘FedEx’ respectively. 27. Drag an Invoke activity into the first case for USPS. Drag a wire from the

Invoke to the JMS_USPS partner link. The Invoke dialog opens. 28. Set the Name to Invoke_USPS and use the green plus sign icon to create the

input variable using the default values. Click OK.

29. Click OK.

Section 9.4

Adding JMS to Fulfillment 9-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

30. Repeat the above steps to add invokes for UPS and FedEx.

Now, you need to assign data to the input variables for the three service invokes. 31. Drag an Assign activity into the first case just before the Invoke_USPS. 32. Open the Assign and create a copy operation to copy the fulfillment data to the

input variable for the USPS service.

33. Click OK twice. 34. Repeat the same steps for the remaining two services (UPS and FedEx).

The final path, the otherwise branch, can be handled in one of two ways. You could choose to do something at this point such as raise a fault. That would be appropriate if, in the future, there is a fourth carrier setting returned from the rule and you wanted to be sure to flag it so that code could be added to handle it. Instead, for now, just do nothing. You can either remove the otherwise block or put an Empty activity along this branch.

9-10 Adding JMS to Fulfillment

Section 9.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

35. Remove the otherwise branch to do nothing in the otherwise part of the switch. 36. Save All your work.

And that completes the JMS addition to the fulfillment process. Give it a try.

9.5 Deploying the application Deploy the POProcessing in the same way as before using the Deploy command on the Project Menu. Remember to elect to overwrite any previous version. Read Appendix A Deploying and Running a Composite Application to refresh your memory on how to deploy if you need to.

9.6 Testing the application Again, use the flow view in the EM console to see that everything is working correctly. 1.

Open Enterprise Manager (EM) console and click POProcessing. Click Test.

2.

Using the input files you will find in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/inpu t, run three tests, one each with small, large and extra large orders.

3.

View the instance data using EM console. For the extra large order, you have to submit the approval task to complete the process.

4.

By using Launch Message Flow Trace, verify that the FulfillmentRules returns USPS, UPS and FedEx as the delivery carrier appropriately. Verify the JMS message is sent appropriately by viewing the instance flow details and by using the WLS Console (use the Admin Console bookmark)

Section 9.5

1.

Open Services/Messaging/JMS Modules/SOAJMSModule

2.

Click demoFulfillmentQueue/Monitoring

3.

Select checkbox for SOAJMSModule!demoFulfillmentQueue

Adding JMS to Fulfillment 9-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click Show Messages to view the messages waiting in the queue.

9.7 Operations and naming This section gives you all of the operations and names for objects created in this chapter. Experienced users can use this for creating the objects in this chapter quickly. Any questions on details for a particular operation listed here can be found in the preceding sections. The information is divided by the sections in this document. Add the JMS adapters



In composite: JMS Adapter: JMS_USPS



OEMS service Oracle Weblogic JMS



Service Connection: MyApplicationServer



Define this Adapter Interface later



Operation: Produce Message,



Produce Operation Parameters: demoFulfillmentQueue.



JNDI name: eis/Queue/demo



Message schema: fulfillment.xsd > Fulfillment



Repeat for: JMS_UPS and JMS_FedEx, wire all from FulfillmentProcess

Invoke the services from BPEL



FulfillmentProcess BPEL process > Switch below the Business Rule



Expand the Switch and add two more switch cases.



Double-click on the bar and set Name: USPS



Expression: bpws:getVariableData('outputVariable','payload','/ns2:CarrierSelection/ns2:carrier' ) = 'USPS'



Repeat for the next two cases, setting the condition for ‘UPS’ and ‘FedEx’ respectively.



Invoke: Invoke_USPS inside case block, wire to the JMS_USPS



Input variable: defaulted



Repeat for UPS and FedEx.



Assign: Assign_USPS just before Invoke_USPS.



Copy From: inputvariable > fulfillment ,



Copy to: Invoke_USPS_Produce_Message_InputVariable.



Repeat for UPS and FedEx.

The application is completed. Continue with Section 9.5 above to deploy and test your application. 9-12 Adding JMS to Fulfillment

Section 9.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

A Deploying and Running applications A A.1 A.2 A.3 A.4 A.5 A.6 A.7

Deploying and Running applications ...................................................................................................... 1 Introduction ........................................................................................................................................ 1 Start the Oracle WebLogic Server .................................................................................................... 1 Create a Connection to Oracle WebLogic Server .......................................................................... 2 Deploying Composites to the Application Server ......................................................................... 5 Deploying Human Task form to the Application Server ............................................................. 8 Running and testing the application with EM ............................................................................... 9 Getting the service description (WSDL) ........................................................................................13

A.1 Introduction A SOA composite application first has to be deployed to an application server container and then run from there. A Human Task form project is not a SOA Composite and has different deployment steps. You will find the details in the following sections.

A.2 Start the Oracle WebLogic Server You need to start both the admin server and the SOA managed server. 1.

Open the Start/Stop Weblogic Server(s) icon on the desktop. The Server Control window appears.

2.

Select the Start radio button as the action and click the OK button. The Start WLS Servers window appears.

3.

Toggle on the checkbox beside SOA and click the OK button. The Starting Servers window appears and gives you feedback as first, the admin server is started and then, the SOA managed server is brought to life. Wait until “OK” appears in the window to let you know that startup is complete.

4.

Close the Starting Servers pop-up window. Then, close the Checking Server Status pop-up window.

Once the servers are up, you can use these links to control your environment: The link for the WebLogic console is http://localhost:7001/console (login with weblogic/welcome1) The link for the EM console is http://localhost:7001/em (login with weblogic/welcome1)

Section A.1

Deploying and Running applications A-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

The link for SOA worklist app http://localhost:7001/integration/worklistapp

When you want to stop your servers, complete the following. 1. Open the Start/Stop Weblogic Server(s) icon on the desktop. The Server Control window appears. 2.

Select the Stop radio button as the action and click the OK button. The Stop WLS Servers window appears.

3.

Toggle on the checkbox beside SOA and click the OK button. The Stopping Servers window appears and gives you feedback as first, the admin server and SOA managed server are stopped. Close all pop-up windows.

A.3 Create a Connection to Oracle WebLogic Server You need to create a connection from JDeveloper to the Oracle WebLogic Server configured for Oracle SOA Suite in order to deploy from JDeveloper. From the Application Menu, select New.

In the New Gallery, in the Categories tree, select General, and then Connections. Select Application Server Connection

A-2 Deploying and Running applications

Section A.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Click OK. The Create Application Server Connection Type page is displayed. Enter MyAppServerConnection in the Connection Name field and select WebLogic 10.3 from the Connection Type list.

Click Next. The Connection Authentication page is displayed.

Section A.3

Deploying and Running applications A-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Enter weblogic for the User Name and and welcome1 in the for Password. Click Next. The Configuration page displays. Enter the following values: Weblogic Hostname (Administration Server): localhost Port: 7001 WLS Domain: domain1

Click Next. The Test page displays. Click Test Connection.

A-4 Deploying and Running applications

Section A.3

The following status should appear:

If the test is unsuccessful, ensure that Oracle WebLogic Server status is RUNNING, and retry the test. Click Next, and in the Finish page, click Finish.

A.4 Deploying Composites to the Application Server After you have created your own composite, you can deploy it to the server. See the next section to deploy a Human Task form project which has a different procedure. The Deploy command rebuilds the app and writes the binary to disk. It also brings up the deployment plan dialog before deploying. When the server is stopped and restarted, the applications will remain deployed. 1.

Section A.4

In the project menu – right-click on the project name - select Deploy and follow the menu to select MyAppServerConnection. Make sure you have the project menu and not the application menu in order to see this option.

Deploying and Running applications A-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Check for this error.

It means your SOA managed server is not running. If you think both the Admin Server and the SOA Servers are running, restart JDeveloper and stop the servers and restart them in the right order (start first the Admin Server and then the SOA Server). 3.

SOA Deployment Configuration Dialog opens. If you are redeploying your application, you must either select the checkbox to overwrite the previous version or you can enter a new version. Otherwise the deployment will fail.

A-6 Deploying and Running applications

Section A.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click OK.

5.

If this is the first time you are deploying since server startup or if the connection has timed out, you are prompted for the admin user name (weblogic) and password (welcome1):

6.

Enter the values and click OK

Next the application is built and deployed. If there are no compilation errors, you will see on the SOA log, BUILD SUCCESSFUL and then the deployment starts.

Section A.4

Deploying and Running applications A-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

In the Deployment log, view the details of the deployment.

Wait for your application to be deployed and then you can run and test it.

A.5 Deploying Human Task form to the Application Server If you want to deploy an application that is not a SOA composite to the application server, you can do that from JDeveloper too. The deployment steps are slightly different. The Human Task form is a Java application that is separate from the composite. You must follow these instructions to deploy the form.

1.

In JDeveloper, open the Application Menu not the Project menu. Do not rightclick on the project. You can find the Application menu in the toolbar or you can right-click on the application name to bring up the menu or you can click the

A-8 Deploying and Running applications

Section A.5

drop-down menu icon to the right of the application name to open the application menu. You will see your Human Task application listed in the menu (see image).

2.

Select the Human Task application and then select the application server connection.

3.

Watch the Deployment log and wait for the application to finish deploying.

A.6 Running and testing the application with EM Often you'll have an application or some GUI-based front end to invoke your service so you can test it. But usually you will start developing your services first and won't have an application to test them with. The Oracle Enterprise Manager console allows you to run your service with any input so you can test it anytime. 1.

Open your browser and navigate to EM. http://localhost:7001/em (The first time these screens are run after starting the server they will be slow as the page is unpacked, compiled, and loaded into memory.)

Login with weblogic/welcome1

Section A.6

Deploying and Running applications A-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

The Enterprise Manager opens to the “farm” view, containing all of the managed servers managed by this Admin Server. You can see the status of your SOA Server as well as the deployed Java applications and SOA composites.

In this view, you can see the BAM managed server has not been started. The SOA composites are listed in two places.

A-10 Deploying and Running applications

Section A.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Select your composite from the list of composites on the main farm view or on the left navigation bar. The composite page opens.

On this page, you can see the Recent Instances (none yet), Faults, the Component Metrics (there is only one component in this composite), and the Services and References Metrics. 3.

Click Test button at the top of the screen. The Test page opens.

You can see the WSDL location, Operations list, and two tabs, Request and Response. Scroll down to the Input Arguments section. Section A.6

Deploying and Running applications A-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Specify your values for the payload. You can use the HTML form on the Tree View, which is default, or the XML source on the XML View. For smaller amounts of the data, using the HTML form view is probably easier. But for large payloads, it's easier to copy-and-paste your data into the XML View.

5.

Enter the data and click Test Web Service. When the composite completes, the screen changes to the Response tab and the returned value shown. From here, you can jump directly to this particular composite instance and view the flow.

A-12 Deploying and Running applications

Section A.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

Click Launch Message Flow Trace The Flow Trace screen opens and you can see the flow of your composite and the status of each service, component and reference.

7.

Click on the component to drill down into the Instance Details of the component

Close the Flow Trace window, click on your composite to return to the composite page. You can see your Instance ID listed. You can return to the Flow Trace screen by selecting the Instance ID.

A.7 Getting the service description (WSDL) You can get the service description, or WSDL, of your composite from the Test page. This is useful because you may need it for applications to access your service, or to expose your service to others. 1.

Section A.7

Open the Test page for the composite you are interested in.

Deploying and Running applications A-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

In the Test page you see the WSDL location. You also can see the Endpoint URL for each of the Operations defined in the WSDL.

A-14 Deploying and Running applications

Section A.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

B Managing the lifecycle of a SOA composite application B.1 Introduction to SOA lifecycle This lab exercise will give you a brief introduction to various techniques that can be used to manage the lifecycle of SOA composite applications. Oracle SOA Suite provides multiple facilities to help in this area: 

Variety of deployment methods: o

JDeveloper, the development environment

o

Enterprise Manager, the management & monitoring environment

o

Command line, in an interactive fashion

o

ANT or Python scripts



Ability to simultaneously deploy multiple versions of a given composite, and specify a default version



Configuration plans to customize environment-specific values (ex: a web service URL that is different in the test environment than in the production environment)



Built-in support in JDeveloper for version control systems such as Subversion.

B.2 Lab overview In this lab you will create a configuration plan which surfaces a property that can take on different values. This simulates the process of deploying with different values to your different environments: Development, Test and Production.

Section B.1

Managing the lifecycle of a SOA composite application B-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

B.3 DEVELOPMENT environment B.3.1 Surfacing binding properties at the composite level 1. In JDeveloper, open your previously completed POProcessing composite (or the prebuilt solution for chapter 9). 2. Open composite.xml 3. Select the WriteApprovalResult external reference. 4. View the properties using the Property Inspector in the lower-right pane. You may need to enlarge or scroll the pane to see all of the sections. If you do not see the Property Inspector, select it from the View menu in the toolbar. 5. Using the Property Inspector, we are going to add a binding property. Scroll to the Binding Properties section and select the Add icon (green plus sign).

B-2 Managing the lifecycle of a SOA composite application

Section B.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6. Select FileNamingConvention from the drop-down menu for the property Name and enter test_%SEQ%.xml for the Value. 7. Click OK.

8. Check the source (click Source tab) of composite.xml to see that you have surfaced a binding property in composite.xml.

Section B.3

Managing the lifecycle of a SOA composite application B-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9. Save All

B.3.2 Generating and validating a deployment plan 10. From the Projects Explorer, select composite.xml 11. Right-click on composite.xml and choose Generate Config Plan 12. Name your plan POProcessing_dev_cfgplan.xml 13. Click OK. The plan should automatically open in text mode in JDeveloper. 14. Locate the reference for WriteApprovalResults and edit the FileNamingConvention property to orderoutput_%SEQ%.xml

15. In addition, in the wsdlAndSchema section, add the PhysicalDirectory jca property. This is the directory that you configured for the file adapter to write to. Enter another directory, for instance: “/home/oracle/tmp/out”.

Note that you can restrict the scope of this global replace to a single file by only leaving WriteApprovalResults_file.jca in the list of files to consider for this search & replace. Now it is time to validate your new config plan to ensure it works as expected: B-4 Managing the lifecycle of a SOA composite application

Section B.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

16. Save All. 17. Right-click on composite.xml 18. Select Validate Config Plan 19. Select OK in the Composite Configuration Plan Validator dialog. 20. The report.log opens automatically. You should see the following:

21. Finally, deploy from JDeveloper and attach this deployment. Give this new deployment a different revision ID like 2.0. See that your configuration plan is automatically selected, at the right side of the window, for use:

Section B.3

Managing the lifecycle of a SOA composite application B-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

22. Click OK to start deployment. 23. Use Enterprise Manager to test your application to ensure that the file adapter now writes all message to /home/oracle/tmp/out with a name orderoutput_.xml.

B.4 TEST environment B.4.1 Compiling and packaging from the command-line with ANT Administrators typically do not want to work with IDEs and prefer to operate from the command line or with scripts. Let’s take the role of an administrator in this section and exclusively work from the command line. 24. First, open a terminal window (on the desktop: Applications/Accessories/Terminal) and set your environment for command line deployment via ANT. export PATH=/home/oracle/Middleware/modules/org.apache.ant_1.7.0/bin:$PATH export JAVA_HOME=/home/oracle/Middleware/jdk160_11

B-6 Managing the lifecycle of a SOA composite application

Section B.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

25. Navigate to the following directory cd /home/oracle/JDevHome/jdeveloper/bin 26. Look at the available ANT commands and explore ANT help: ls ant-sca* ant-sca-compile.xml ant-sca-package.xml

ant-sca-deploy.xml ant-sca-test.xml

ant-sca-mgmt.xml ant-sca-upgrade.xml

Use ant –f help (like ant –f ant-sca-package help) to get usage information for a given command. 27. Compile and package POProcessing using the ant-sca-package command. This command also sets the version number. ant -f ant-sca-package.xml -DcompositeDir=/home/oracle/jdeveloper/mywork/POProcessing/POProcessing -DcompositeName=POProcessing -Drevision=6-cmdline -Dscac.application.home=/home/oracle/jdeveloper/mywork/POProcessing

If successful you should see a “BUILD SUCCESSFUL” message. 28. Check for the [jar] message that will tell you where the script is writing the resulting SAR file. We’ll need this in the next step. [jar] Building jar: /home/oracle/jdeveloper/mywork/POProcessing/POProcessing/deploy/sca_POProcessing_rev6cmdline.jar

B.4.2 Deploying from the command line with ANT Now, we’ll deploy this SAR file from the command-line using ant-sca-deploy.xml. 29. Use ant-sca-deploy.xml to deploy the previously packaged SAR file: ant -f ant-sca-deploy.xml -DserverURL=http://localhost:7001 DsarLocation=/home/oracle/jdeveloper/mywork/POProcessing/POProcessing/deploy/s ca_POProcessing_rev6-cmdline.jar -Doverwrite=true -Duser=weblogic -Dpassword=welcome1 -DforceDefault=true Dconfigplan=/home/oracle/jdeveloper/mywork/POProcessing/POProcessing/POProcess ing_dev_cfgplan.xml

Watch the feedback and look for the “Deploying composite success” message.

Section B.4

Managing the lifecycle of a SOA composite application B-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

B.5 PRODUCTION environment B.5.1 Deploying from Enterprise Manager In this section we will explore the deploy options from Enterprise Manager. In Enterprise Manager, right-click on soa-infra and select the SOA Deployment / Deploy option:

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Point Enterprise Manager to your local SAR file and configuration plan. The local SAR file is at: /home/oracle/jdeveloper/mywork/POProcessing/POProcessing/deploy/sca_POProcessing_rev6-cmdline.jar

The configuration plan is at: =/home/oracle/jdeveloper/mywork/POProcessing/POProcessing/POProcessing_dev_cfgplan.xml

B-8 Managing the lifecycle of a SOA composite application

Section B.5

Click Next to proceed. Click Next again to accept the default target for deployment. An error message appears indicating that the SAR file is already deployed and that it needs to be undeployed before it can be deployed. Just click OK. You can use the Enterprise Manager to undeploy the application (right-click on soa-infra and select the SOA Deployment / Undeploy option ) and then retry deployment if you have time. Otherwise, just move on. We trust you understand the spirit of this deployment exercise using Enterprise Manager.

Section B.5

Managing the lifecycle of a SOA composite application B-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

C Unit Testing C.1 C.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9

Introduction................................................................................................................................................. 1 Designing the flow ..................................................................................................................................... 2 Create the Unit Test .................................................................................................................................... 2 Set the inbound message ........................................................................................................................... 3 Set the simulated message ......................................................................................................................... 5 Set the assertion for success ...................................................................................................................... 6 Set the assertion for failure ........................................................................................................................ 8 Deploying the application ........................................................................................................................10 Testing the application..............................................................................................................................10

C.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/apC-UnitTest To run this solution, you must have completed labs through chapter 9. Alternatively you can do the setup in chapter 1 and use the solution from chapter 9 located at ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutio ns/ch9-JMSAdapter The test framework supports testing at the SOA composite level. In this type of testing, wires, binding component services, service components (such as BPEL processes and mediator) and binding component references are tested. In this chapter, you create a Unit Test for the POProcessing composite, including 1. An inbound message for receivePO. 2. A simulation of a callback message returned by a service 3. An assertion to verify the order status at completion 4. An assertion that will always fail for the input we provided in this test case When completed, the unit test looks like this in JDeveloper:

Section C.1

Unit Testing C-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

C.2 Designing the flow You will modify POProcessing to add a unit test that sets the inbound message, the simulation message, and the two assertions. The inbound message will be a valid order (valid credit card) with an order total between 1000 and 5000 so that it triggers the approveLargeOrder process but not the human task (for convenience). The simulated message is the return from the credit validation service returning the correct value. The first assertion is on the data being passed to the WriteFile service, checking that the value of status = ‘approved’ which is the expected value for this input data. The second assertion is on the data being passed to FulfillmentProcess, checking that the customer id is 9999. Since the customer id is actually 1111, this test will always fail. This last assertion shows what happens when the data being checked is not the expected value.

C.3 Create the Unit Test 1.

Open the POProcessing project in JDeveloper. In the Application Navigator expand the SOA Content folder and right-click on testsuites folder.

2.

Select Create Test Suite

3.

Name the test suite logicTest

C-2 Unit Testing

Section C.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Click OK

5.

Name the test TestDelivery

6.

Click OK Notice the composite view changes slightly to show you are in unit test creation mode now. The swim lanes on the left and right are yellow. Notice that the tab for this window displays the name: testDelivery.xml. Note: You can view the normal composite editor by selecting the Return to SOA composite diagram button at the top of the window.

C.4 Set the inbound message 7.

First, we’ll create an inbound message for receivePO. Double-click the binding component receivePO or right-click and select Create Initiate Messages

8.

In the Initiate Messages dialog that appears, insert the following payload (copy and paste from file) replacing the text.

Section C.4

Unit Testing C-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

File Name: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/input/po -unittest.txt Contents: 1111 2222 TV-LCD electronics 1260 1 initial Mastercard 8765-8765-8765-8765

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

This creates an order for Customer with ID=1111 and a $1260 purchase.

9.

Click OK. After closing the dialog, you will see a blue arrow on the inbound component indicating there is a message set for that service.

C-4 Unit Testing

Section C.4

C.5 Set the simulated message Now, simulate a callback message returned from an asynchronous web service. 10. Double-click the wire between BPEL process approveLargeOrder and the

getCreditCardStatus Web service.

11. On the Wire Actions window, go to the Emulates tab and click on the plus sign

to create an emulation:

Section C.5

Unit Testing C-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

12. Click on Generate Sample to have a sample response automatically created for

you. Next, edit the XML fragment and change the response value to VALID, as if the Web service would return a response that the credit card number is valid

13. Click OK to dismiss the Create Eumulate window and click OK again to close

the Wire Actions window. Notice that to wire between approveLargeOrder and getCreditCardStatus becomes dashed and you see an arrow indicating that a message emulation is in place.

C.6 Set the assertion for success 1.

Now, perform an assertion to verify order status. Double-click on the wire between routePO and WriteApprovalResults

2.

In the Asserts tab, add an assertion by selecting the green plus sign.

C-6 Unit Testing

Section C.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

To check only part of the message, click on Browse button to select only one field of the XML structure:

4.

Select only the imp1:status

5.

Click OK

6.

For assert value enter approved in order to check the purchase order status.

Section C.6

Unit Testing C-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

Click OK to dismiss the Create Assert window and click OK again to dismiss the Wire Actions window.

C.7 Set the assertion for failure Now, you want to create an assertion that will always fail for the input we provided in this test case. 8.

Double-click the wire between approveLargeOrder and FulfillementProcess

C-8 Unit Testing

Section C.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9.

In the Asserts tab, add a new assertion (green plus sign) and click again on Browse to select only part of the message, and select only CustomerID

10. For Assert Value enter 9999. This assertion will fail because the initial payload

that we supply has customerId=1111.

Section C.7

Unit Testing C-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

11. Click OK to dismiss the Create Assert window and click OK again to close the

Wire Actions window. 12. Save All your work.

The whole Test should look like this :

C.8 Deploying the application Deploy the application in the same way as before using the Deploy command on the Project Menu. Read Appendix A Deploying and Running a Composite Application to refresh your memory on how to deploy if you need to. Since you already deployed POProcessing once before, you must either choose a new version number or select Overwrite any existing composite when deploying. If you do overwrite the previous composite, the existing instances for the version become stale and can no longer be viewed.

C.9 Testing the application 1.

After deploying, in the Enterprise Manager console, click on the POProcessing application and then open the Unit Tests tab.

2.

You see your testDelivery.xml test suite listed.

C-10 Unit Testing

Section C.8

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Select the checkbox for TestDelivery.xml in the Select column and click Execute

4.

For Test Run Name, enter: FirstRun. Then, click OK.

5.

After the test has completed, you see that the overall status is marked as Failed:

6.

Scroll down a little to see the details about the assertions we inserted

Section C.9

Unit Testing C-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

Note that the first one is Failed as expected because the CustomerID is 1111 and not 9999

8.

The second one is True as the status passed to ‚WriteApprovalResult‛ is approved

9.

Click the Composite Instance ID in the last screen. You see the complete flow of the process. Note that the ‚getCreditCardStatus‛ was never called, because of the response Emulation you inserted.

C-12 Unit Testing

Section C.9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

D Fault Handling

D.1 Introduction Note: The solution for this chapter can be found in: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solu tions/apD-FaultHandling To run this solution, you must have completed labs in chapter 9. Alternatively you can follow the setup in Chapter 1 and use the solution from Chapter 9 located at: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solu tions/ch9-JMSAdapter This lab exercise will give you a brief introduction to handling exceptions in a SOA composite. Oracle SOA Suite provides sophisticated error handling capabilities that enable you to define fault handling easily at various levels in a composite. It allows you to handle both system-generated errors, called system faults, as well as application-generated ones, called business faults. The BPEL specification provides rich fault handling constructs for catching exceptions and acting on them. The mediator, on the other hand, provides no such capability. However, in BPEL, the code can get quite complex with fault handling code duplicated for common exceptions. Oracle SOA Suite provides a policy-based fault handling mechanism that allows you to define how faults are handled. The policies can be bound to either the composite as a whole or can also be associated with individual components. In this lab you will implement very simple exception handling using both the BPEL fault handling constructs as well as policy-based fault handling.

D.2 Handle Remote Faults In this lab, you will define a fault handling policy for processing a remote fault. To generate, a fault you will make the getStatusByCC service unavailable and test to see how the composite handles the exception. You will then add a fault handling policy to handle the exception

D.2.1 Prerequisites This lab requires Enterprise Manager console to execute some of the steps. If you just did the lab on unit testing, you’ll want to delete the test suite and redeploy POProcessing. To delete the test suite, right-click on POProcessing / Section D.1

Fault Handling D-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

SOA Content / testsuites / logicTest and select the Delete Test Suite option. Then, redeploy POProcessing.

D.2.2 Test service unavailability 2.

To simulate an unavailable service, shutdown the validationForCC composite. To do that, navigate to the Application Server Navigator in JDeveloper (ViewApplication Server Navigator, not Application Navigator).

3.

Expand the SOA node under MyAppServerConnection and select validationForCC

4.

Right-click and select Turn Off

5.

From the Enterprise Manager in the web browser invoke the POProcessing composite (receivePO service operation) using the Test button on the POProcessing page. Use the po-large-iPodx30.xml file from ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/schemas to

submit an order that is over $1000 so the credit card validation is called. 6.

D-2 Fault Handling

In Enterprise Manager, click on the new instance id of the POProcessing composite and then click approveLargeOrder in the Flow Trace to view the details. You should see that the composite has terminated with a remote fault with no way to restart it if you were to make the getStatusByCC service operation

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

available.

D.2.3 Add policy-based fault handler to do manual recovery Add a fault handling policy to catch this exception and make it recoverable via manual intervention. 1.

Copy files fault-policies.xml and fault-bindings.xml from ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sche mas to POProcessing directory (where the composite.xml for POProcessing is located). cd ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/schemas cp fault-policies.xml ~/jdeveloper/mywork/POProcessing/POProcessing cp fault-bindings.xml ~/jdeveloper/mywork/POProcessing/POProcessing

Click the Refresh button (blue arrows cycle icon at the top) in the Application Navigator in JDeveloper to have the files show up in the list. The fault-bindings.xml file has been created for you. It binds the POProcessing composite with a fault policy called POProcessingFaults defined in the faultpolicies.xml file. The fault-policies.xml file is partially complete. You will add fault handlers here as you step through this lab. 2.

Open the fault-policies.xml file in JDeveloper and add the following to handle all remote faults that occur in any component in the POProcessing composite under the comment referencing the text ‚Step D.2.2.2”

3.

Section D.2

Save All and deploy the POProcessing composite.

Fault Handling D-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Invoke the POProcessing composite using the web service tester (Test button) in Enterprise Manager. Run through the p0-large-iPox30.txt transaction.

5.

Select the instance id of the newly invoked POProcessing to view the flow trace:

In the flow trace window, click on approveLargeOrder and view the Audit Trail tab. You will see that the activity has faulted as before, but this time, it is waiting for a manual recovery. The circled icon indicates that the fault is recoverable:

6.

Before you try recovery, start the validationForCC composite from the Application Server Navigator in the JDeveloper as you did above. This time, select Turn On to startup the composite. You can also do this from Enterprise Manager by selecting the Start Up… button on the validationForCC page.

7.

Back in the Audit Trail tabbed window, select the Faults tab.

8.

Click on the row containing the fault. This will show the fault details including the contents of the input variable to the invoke.

D-4 Fault Handling

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

9.

Select Retry as the Recovery Action and click on the Recover button.

10. Select Yes when prompted if you want to continue. 11. You should see the fault clear up from the Faults tab. Click on the Audit Trail

tab to view the BPEL flow. You may need to refresh the window by clicking on the cycle icon in the upper-right corner. You should see that the BPEL process has completed execution successfully.

Section D.2

Fault Handling D-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

D.2.4 Handle faults in BPEL BPEL provides comprehensive error handling constructs for catching exceptions and handling them appropriately. You can choose to handle exceptions within the process itself rather than using fault-handling framework. For example, in the current implementation of validateForCC, while doing the credit card validation, if a non-existing credit card number is passed to the service, it just returns an empty response. If the service were to throw a specific exception for such unknown credit card numbers, you would want to catch that exception and set the status in the Order appropriately. This lab illustrates this scenario. You will modify the validateForCC composite to call a database store function for validating credit cards starting with a specific number. This store function throws a PL/SQL application exception with an error code of 20001 for credit card numbers not in the database. In the BPEL process you will catch and handle the fault. Create the store function in the SOADEMO schema by running the SQL script create_validate_cc.sql available in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sql using the soademo user. In a Terminal window, enter these three commands: . /home/oracle/bin/oracle_xe_env.sh cd ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sql sqlplus soademo/soademo @create_validate_cc.sql

You’ll see the output: ‚Function created.‛ Type Exit to leave the SQL> prompt. 1.

Open the validateForCC composite and drop a Database Adapter to the External References swim lane. Step through the wizard to create the reference to the store function just created using the following values. Service Name

validateCC

JNDI Name

eis/DB/soademoDatabase

Operation Type

Call a Stored Procedure or Function

Procedure

Browse and select VALIDATECC

2.

Finish the wizard by accepting the defaults.

3.

On the composite, wire the RouteRequest mediator component to validateCC

4.

Open the RouteRequest mediator and add a filter expression for getCreditValidationSelect to route all requests for credit card numbers that don’t start with 2.

D-6 Fault Handling

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Add a filter expression (very similar to the above) for validateCC to route only those requests that have credit card numbers starting with 2 to the database stored function.

6.

Create a new transformation for the validateCC route, mapping CCNumber to db:CC_NUMBER. You don’t need a transformation for the reply because this service only raises a fault, it doesn’t reply.

7.

Save All and deploy the validationForCC composite. Elect to overwrite any existing deployment.

8.

Test validationForCC using web service tester in the Enterprise Manager. Use credit card number: 1234-1234-1234-1234. You should see a value for reply in the response of VALID.

9.

Try the test again, except this time change the credit card number to 2234-12341234-1234. You should see an error – ORA-20001 UNKNOWN CREDIT CARD Now, we’ll update the BPEL process to catch the fault.

10. Open the POProcessing composite in JDeveloper. 11. Open the approveLargeOrder BPEL process. 12. Add a new Scope activity right above the invokeCCStatusService activity.

Rename it to checkCC. 13. Expand the checkCC scope and move the invokeCCStatusService activity into

the scope.

Section D.2

Fault Handling D-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

14. Click on Add Catch Branch icon to add a catch branch and click on + to expand

it:

15. Double click on the Catch (red diamond) and enter the Fault details. For

Namespace URI and Local Part click on the browse icon and select System Faults  bindingFault. Auto create the fault variable (green plus sign icon) and accept the default name, FaultVar. 16. Click OK to close the Catch dialog. The catch icon is now labeled

‚bpelx:bindingFault.‛ 17. Drop a Switch activity into the catch block.

D-8 Fault Handling

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

18. Expand the switch (+ sign). Open the expression editor for the branch

and build an expression checking for code in FaultVar for ‘20001’.

19. Add an assign activity called Assign_UNKNOWNCC in the branch to

assign the literal string ‘UNKNOWN CC’ to the variable invokeCCStatusService_execute_OutputVariablereplycreditcardStatus. 20. In the branch, drop a Throw activity. Open the Throw activity and

name it Throw_Binding_Fault. For Namespace URL and Local Part, use the browse tool to select System FaultsbindingFault. For the fault variable use the browse tool and select the FaultVar fault variable created earlier. 21. The new updated flow should look like this:

22. Save All. 23. The fault-handling framework takes precedence over the BPEL catch so you need

to have the fault-handling framework re-throw the fault so that BPEL can process it. Add the following in the fault-policies.xml after the comment with text ‚Step D.2.4.20” Section D.2

Fault Handling D-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

$fault.code="20001"

24. Save All. 25. Deploy and test the POProcessing composite. Overwrite any existing

deployment. Use the po-large-iPodx30.xml from ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/input. But

change the credit card number to start with 2. In the flow trace, you should see the fault being re-thrown from the fault handling framework and being caught and processed in the BPEL process.

D.2.5 Using A Custom Java Fault Handler In addition to some of the pre-defined actions like humanIntervention, rethrowFault and abort, you can also define your own custom fault handler using Java. In this exercise, you will change the policy for bindingFault and, instead of rethrowing the fault, you will use a custom Java class to handle it. 1.

D-10 Fault Handling

Install the custom Java handler by copying the provided myfaulthandler.jar available in

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/lib to the lib directory of your WebLogic Server domain home. That directory is: /home/oracle/Middleware/user_projects/domains/domain1/lib. cp ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/lib/ myfaulthandler.jar /home/oracle/Middleware/user_projects/domains/domain1/lib

The JDeveloper project for this JAR is available in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solu tions/apD-Fault-handling/MyFaultHandlerApp 2.

Restart the managed server by using the Start/Stop Weblogic Server(s) control on the desktop.

3.

Modify the fault-policies.xml and change the bindingFault handling from:

$fault.code="20001"

to: $fault.code="20001"

4.

Modify the fault-policies.xml and change the logFileDir property from:

to:

Section D.2

Fault Handling D-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Ensure that the directory /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutor ial/po/log directory exists. This is where the Java fault handler will write its messages.

6.

Save your fault-policies.xml changes. Deploy the POProcessing composite and test using the po-large-iPodx30.xml input with the credit card number changed to start with 2. You should see myfaulthandler.log in /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutor ial/po/log directory. You should also see, by looking at the flow trace in Enterprise Manager, that the POProcessing composite handles the fault. You’ll see a ‚FAULT RECOVERY‛ by MyFaultHandler.

D.2.6 Handle Mediator Faults Since the Mediator doesn’t provide any built-in fault handling mechanism, the policy-based fault handler is the only way to catch and handle exceptions occurring in the Mediator. A variety of exceptions can be caught ranging from adapter exceptions to transformation exceptions. In this exercise, you will define a fault handler for catching all Mediator faults and use the custom Java handler to write to a log file. To force the Mediator to fault, we will simulate a disk write error and have the File adapter throw an exception. 1.

Modify fault-policies.xml file and add the following after the comment containing the text ‚Step D.2.6.1”:



2.

Add the following after the comment starting with Step D.2.6.2. This defines a java action using the same custom java class that you used in the earlier exercise but uses a different set of properties and also defines a different action to be performed on return from the custom Java call

3.

D-12 Fault Handling

Add the following after the comment starting with Step D.2.6.3. This defines the property set that is to be used by the new JavaAction.

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

4.

Save All.

5.

Open the routePO mediator component and change the route for the filter ‚quantity < 1000‛ to Parallel from Sequential.

6.

Select Yes when prompted

7.

You should see this change when you the rule has been moved to the end:

Without this change, the fault policy handler will not get control when a fault occurs in the Mediator. This is because sequential routes are executed in the same thread and transaction context as the caller of the mediator service. If a fault occurs while executing a sequential route, it is thrown back to the caller and the fault handler is bypassed. Otherwise, it could potentially break the transaction. In the case of a parallel route, a new thread and new transaction Section D.2

Fault Handling D-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

context is created by the Mediator. It is within this thread that the route is executed. If a fault occurs while executing a parallel route and a matching fault policy exists, the appropriate fault handler is executed. 8.

Save All.

9.

Deploy the POProcessing composite again electing to overwrite existing components.

10. Change the permission of the directory /home/oracle/tmp to read only. This

will force an error when the file adapter is writing the purchase order file. Open a Terminal window and enter: chmod –w /home/oracle/tmp to make the directory read only Note: You may also need to change the permissions on /home/oracle/tmp/out if your file adapter is still writing there based upon a previous exercise. 11. Test the POProcessing composite using the po-small-Headsetx1.xml. The

process will try to write the approval to the ~/tmp directory and fail. You should see a file mediator-faults.log in the ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/log directory. The flow trace in Enterprise Manager should show the composite waiting for manual recovery. 12. Try submitting the po-large-iPodx30.txt. Did the fault handler execute?

Refer to D.2.6.6 for explanation of this behavior.

D-14 Fault Handling

Section D.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

E Enforcing Policies E

Enforcing Policies ................................................................................................................... 1 E.1 Introduction ..................................................................................................................... 1 E.2 Policy attachment in console ......................................................................................... 1 E.3 A quick look at policy management ............................................................................. 3 E.4 Policy attachment in JDeveloper ................................................................................... 3

E.1 Introduction In this section you will experience a simple demonstration of web services policy enforcement. You will learn:



How to attach a policy



How to secure invocation of a composite using web services security user name token (userid/password)



How to propagate identity across a multi-component composite to an invoked service using SAML



Communicate signed and encrypted messages

The composite to be secured with a user name token is the composite POProcessing. The composite to be secured with SAML, encryption and signing is the validationForCC composite.

E.2 Policy attachment in console Web services policies can be attached in JDeveloper and deployed or they can be attached in the Enterprise Manager (EM) console after deployment. In this section, you will use the console.

Section E.1

1.

Go to the EM console and log in.

2.

Click on POProcessing composite link in the left panel.

3.

Click on the Policies tab. No policies are currently attached.

4.

Select receivePO in the Attach To/Detach From drop-down list.

5.

Select oracle/wss_username_token_service_policy at the bottom of the Available Policies list. Click the Attach button above and the policy is added to the Attached Policies panel. Then, click OK. The original window redisplays and your policy now appears attached.

Enforcing Policies E-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Figure 3 Attaching a policy

6.

Using the same steps as above, attach the policy oracle/wss11_saml_token_with_message_protection_client_policy to the attach point getCrediCardStatus.

7.

Similarly, attach the policy oracle/wss11_saml_token_with_message_protection_service_policy to the attach point getStatusByCC in the validationForCC composite.

8.

Test POProcessing. Use po-large-iPodx30.txt as your test input. Be sure to select WSS Username Token on the Request tab’s Security section and specify the userid/password of weblogic/welcome1. Check the message flow trace to see how execution proceeded.

9.

Retest, but this time, specify an invalid password. What error do you see? You should see a “FailedAuthentication” error.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Test validationForCC. Use 1234-1234-1234-1234 for CCNumber. Do

NOT specify any WSS Username Token. What error do you see? Perhaps you saw a “Webservice Invocation failed” error. 11. Now, repeat the same steps you used to attach the policies.

However, this time, detach (Detach button) all the policies. We need E-2 Enforcing Policies

Section E.2

to do this since other labs assume POProcessing is not secured. This will “reset” our composites so further labs will work well.

E.3 A quick look at policy management In the EM console, select Weblogic Domain in the left-hand panel to expand the hierarchy. Then, right-click on domain1 in the left-hand panel. Select Web Services and then Policies. Look at all the policies being managed.

E.4 Policy attachment in JDeveloper To attach policies in JDeveloper, right-click on services, references and components in the composite view (composite.xml) and choose to Configure WS Policies. Try and repeat the exercise you did in the console, but this time, using JDeveloper. As noted above, you will need to detach any policies before moving on to the next labs as the subsequent labs assume that policies are not to be attached.

Section E.3

Enforcing Policies E-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

F. Handling Business Events using EDN

F.1. Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/apF-EDN To run this solution, you must have completed labs through chapter 9. Alternatively, you can run the setup in Chapter 1 and use the solution from Chapter 9 located at ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/ch9-JMSAdapter. This lab exercise will give you a brief introduction to using Event-Driven Network (EDN) in a SOA composite for creating event-based activation. EDN provides functionality for producing and consuming high-level business events without having to configure and manage any messaging services like JMS or Oracle AQ. To illustrate the usage of events, you will modify the existing POProcessing composite to accept new orders from a second source: an event published by another application indicating a new order.

F.2. Modifying the composite to consume events In this step you will modify the POProcessing composite to use EDN. You will add a new mediator component called receiveNewPO that will subscribe to an event called NewPO and send the received PO to the routePO service.

F.2.1. Defining the event

Section F.1

1.

Open the POProcessing application in JDeveloper or use the completed solution from Chapter 9 from ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/ch9-JMSAdapter.

2.

Open the composite.xml and click on the Event Definition Creation icon

3.

In the Event Definition Creation window, enter POEvents as the name of the event definition. Accept the namespace value that is generated.

4.

Add a new event by clicking on the + icon.

5.

Select the PuchaseOrder element from the po.xsd file using the chooser.

Handling Business Events using EDN F-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

Enter NewPO as the name of the event and click on OK to close the Add an Event window.

7.

Click OK to complete the event definition. This closes the Event Definition Creation window.

8.

Save All.

9.

Close the POEvents.edl tabbed panel.

F.2.2.Subscribing to the NewPO Event 1.

Drag and drop a Mediator component onto the composite.

2.

Name the mediator: receiveNewPO

3.

Select Subscribe to Events for the Template

F-2 Handling Business Events using EDN

Section F.2.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section F.2.2

4.

Click on the + to add an event. Select the NewPO event from the Event Chooser window.

5.

Click OK on the Event Chooser dialog and click OK again to accept and create the mediator. Notice that the new receiveNewPO mediator appears on the composite.xml and that it has an event icon (lightning bolt) on its left side.

6.

Save All.

Handling Business Events using EDN F-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

Connect the receiveNewPO mediator to the routePO mediator:

8.

Double-click on the recieveNewPO mediator and define a new transformation map. In the transformation, create a new mapper file and map the all the fields from the source to the target.

9.

Save All and close the mapper file and mediator tabbed panels.

F.2.3. Deploying and testing 1.

Deploy the POProcessing composite to the server.

2.

Start a terminal window and change the working directory to: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/bin.

3.

Open the publish.sh file in the gedit editor (gedit publish.sh) and ensure that the following values are correct: - DB_USER=sh_soainfra - DB_PASSWORD=welcome1 - DB_CONN=localhost:1521:XE

4.

Make sure your Java bin directory is first on the path so you use the right version of Java. Enter the following in your terminal window: export PATH=$JAVA_HOME/bin:$PATH

5.

Change the permissions for the publish.sh script by entering this command in the terminal window: chmod a+x publish.sh

6.

In your terminal window, set your ORACLE_HOME environment variable: export ORACLE_HOME=/home/oracle/Middleware/Oracle_SOA1

F-4 Handling Business Events using EDN

Section F.2.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

7.

Use gedit to edit publish.sh and make sure the first line reads: #!/bin/bash and search for all the occurrences of :: and change them to : (replace double colons with a single colon).

8.

Use vi (so you can see special characters) to edit publish.sh and eliminate all the ^M characters at the end of the lines.

9.

From the ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/bin directory, run the publish.sh script to publish a new purchase order event. The new event is defined in the file new_po_event.xml and can be found in the ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/input directory. ./publish.sh ../input/new_po_event.xml

10. You should see the following output when you execute the command:

11. Open the EM Console in your browser by navigating to

http://localhost:7001/em. Click on the POProcessing composite to view new instances. You should see an instance created for processing the event you just published via the command line. Click on the instance ID to view the flow trace.

Section F.2.3

Handling Business Events using EDN F-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

G Using Service Data Objects (SDO)

G.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/apG-SDO To run this solution, you must have completed labs in chapter 9. Alternatively, you can run the setup in Chapter 1 and use the solution from chapter 9 located at: ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/ch9-JMSAdapter This lab exercise will give you a brief introduction to using Service Data Objects (SDOs) in a SOA composite for accessing and manipulating data. To illustrate the usage of SDOs, you will create a simple SDO using ADF BC and then use this service to retrieve data from the database using the primary key of the table. Then, you will update the retrieved row.

G.2 Preparing for the lab In the SOADEMO schema, create a new table called CUSTOMERS, which contains customer information. In a terminal window, execute these commands: 1.

. /home/oracle/bin/oracle_xe_env.sh cd ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/sql sqlplus SQL> Enter user-name: soademo SQL> Enter password: soademo SQL> @create_customers_table.sql

You’ll likely see a “name is already used by an existing object” as the table may already have been created and populated for you. SQL> exit

G.3 Creating the ADF BC Service 1.

Section G.1

In JDeveloper, create a new application by using the File/New menu, the New Application command from the application menu, or by selecting New Application from the Application Navigator drop-down list.

Using Service Data Objects (SDO) G-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Name your application CustomerSDOApp:

3.

Click Next.

4.

Use CustomerSDO for the Project Name and select ADF Business Components for the Project Technologies.

5.

Select Next and then select Finish to create the empty project. The CustomerSDO project appears in the Application Navigator panel.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

G.3.1 Creating the Business Components 1.

Right-click on the CustomerSDO project in the Application Navigator and select New.

G-2 Using Service Data Objects (SDO)

Section G.3

Section G.3

2.

In the New Gallery window, select ADF Business Components in the Categories list and Business Components From Tables in the Items list

3.

Click OK.

4.

In the Initialize Business Components Project, create a new connection to the database with the soademo schema. For Username/Password, use soademo/soademo. Enter the parameters shown:

Using Service Data Objects (SDO) G-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Use the Test Connection button to test the connection to ensure that the user-id and password are correct. You’ll see the “Success!” message below the Test Connection button. Then, click OK.

6.

Accept the default SQL Flavor and Type Map settings and click on OK to continue.

7.

In the Entity Objects window click on the Query button to retrieve all tables. Select CUSTOMERS from the Available list and move it to the Selected list.

8.

Click Next.

9.

In the Updatable View Objects window, select Customers (SOADEMO.CUSTOMERS) from the Available list and move it to the Selected list and click Next.

10. Accept defaults in the Read-Only View Objects window and click Next. 11. In the Application Module window, enter the Name of the module as

CustomerSDOAppModule and click Next. 12. Click Finish in the Diagram window. 13. Click Save All to save the project

G.3.2 Testing the Application Module You can test the application module created in the previous step. 14. To test it, right-click on CustomerSDOAppModule (not the application name)

and select Run. This will start a Java application called the Oracle Business Component Browser. 15. Double-click on CustomersView1 in the left-hand pane. This will open up a

form. You should see one row that was populated when you created the CUSTOMERS table:

G-4 Using Service Data Objects (SDO)

Section G.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

16. Close the Java application by selecting File>Exit in its toolbar.

G.3.3 Creating the service interface Now, let’s create a service interface for your CustomersView1 view object. 1.

Double-click on the CustomerSDOAppModule in the Application Navigator. This opens the application module configuration panel.

2.

Click on Service Interface in the left pane.

3.

Click on the + sign in the top-right corner to add a new interface. This starts a wizard for defining the new service.

4.

In the Service Interface window, change the name of the Web Service to CustomerSDOService. Use the default target name space and click Next

5.

Click Next on the Service Custom Methods page

6.

In the Service View Instances, select CustomersView1 and add it to the Selected list.

7.

Select the CustomersView1 in the Selected list. This will populate the Basic Operations tab. Select all the operations listed (don’t forget to scroll) and click on Next.

8.

At the Summary step, click Finish

G.3.4 Deploying the service At this point, you now have a new service interface created for the CustomersView1 view object. Before you can deploy this service, you need to ensure that service can participate in a distributed transaction. To do that, you need to configure it to use

Section G.3

Using Service Data Objects (SDO) G-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

the JDBC data source, jdbc/soademoDatabase, that was created for the soademo schema in the earlier labs. 1.

Still in the Service Interface (CustomerSDOAppModule.xml) window, click on Configurations in the left pane.

2.

Edit the CustomerSDOService configuration (use the pencil icon).

3.

Change the JDBC DataSource Name to jdbc/soademoDatabase:

4.

Click OK.

5.

Back on the Configurations page, select CustomerSDOService as the default configuration from the drop-down list.

6.

Click Save All to save the project.

7.

You now need to create a deployment profile. Right-click on the CustomerSDO project in the application navigator and select Project Properties.

8.

Select Java EE Application in the left-hand panel.

9.

Change the Java EE Web Application Name to CustomerSDO-webapp

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

10. Change the Java EE Web Context Root to customer-app 11. Click on Deployment in the left-hand panel. 12. Click New to create a new deployment profile. 13. Select Business Components Service Interface as the Archive Type.

G-6 Using Service Data Objects (SDO)

Section G.3

14. Change the Name to customerSDOProfile. 15. Click OK. 16. Expand the customerSDOProfile and select Middle Tier and click on Edit...

button. 17. Change the Enterprise Application Name to CustomerSDO 18. Change the name of the EAR File to customer-app.ear 19. Click OK. 20. Click OK to close the Project Properties window. 21. Save All to save the project. 22. In the Application Menu in the toolbar, select Deploy->

CustomerSDOApp_customerSDOProfile -> MyAppServerConnection 23. If prompted, select the soa_server1 managed server as the target.

G.3.5 Testing the Customer SDO service To test the service, use Enterprise Manager to test the service. Expand the Farm_domain1/Application Deployments hierarchy in the left pane. Select the Test icon next to CustomerSDOService in the Web Services area:

You should see a Test Web Service page. In the Operations drop-down list, select getCustomersView1. The page will re-render to show only customerid text input in the Request tabbed window Input Arguments area. Enter 1111 and click on the Test Web Service button.

Section G.3

Using Service Data Objects (SDO) G-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

In the Response tabbed window, you should see the appropriate customer information.

G.4 Using the SDO in POProcessing Composite In this step, you will modify the POProcessing composite to use the customer SDO Service. The approveLargeOrder BPEL process will be modified to retrieve the customer information using the customer id in the input order and replace the ID in the input with the name. You will also update the customer information in the database with the information of the last approved order ID and the order value.

G.4.1 Adding the CustomerSDOService as a component 1.

Open your POProcessing application in JDeveloper or use the completed solution from Chapter 9 from ~/SOA11gFoundationTutorial/ SOA11gFoundationTutorial/po/solutions/ch9-JMSAdapter.

2.

In your browser, return to the Enterprise Manager Test Web Service page you used earlier to test CustomerSDO_customerSDOProfile. Find the WSDL URL there and copy it:

G-8 Using Service Data Objects (SDO)

Section G.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

3.

Browse to the URL you just copied to see the WSDL for the CustomerSDO endpoint.

4.

Open the composite.xml for POProcessing and add a new Web Service component to the External References swim lane on the composite diagram.

5.

In the Create Web Service window, enter the name of the service as CustomerSDOService

6.

Paste the URL into the WSDL URL field in the Create Web Service window and press the Tab key to process the URL. The wizard will load the WSDL and populate the Port Type appropriately. Press OK to complete the definition.

The CustomerSDOService external reference is added to the composite diagram. 7.

Section G.4

Connect the approveLargeOrder BPEL process to the CustomerSDOService web service: Using Service Data Objects (SDO) G-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

8.

Save All.

G.4.2 Using the SDO in BPEL In this step, you will use Entity Variables to operate on the underlying Service Data Object. Entity Variable is a new feature introduced in 11g.

G.4.2.1 Creating the Entity Variable 1.

Open the approveLargeOrder BPEL process.

2.

Create a new Entity Variable by clicking on the Variables icon (x) in the main scope for approveLargeOrder.

3.

In the Variables window, click on + to add a new variable.

4.

Name the variable CustomerInfoEV

5.

Select Element and click on the browse icon to select an element. In the Type Chooser, traverse down the Project WSDL Files tree and select customersViewSDO element as shown in the following image.

G-10 Using Service Data Objects (SDO)

Section G.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

Section G.4

Click OK to close the Type Chooser.

Using Service Data Objects (SDO) G-11

7.

Back in the Create Variable window, select Entity Variable and choose the CustomerSDOService for the partner link.

8.

Click OK to dismiss the Create Variable window. Then, click OK to close the Variables window.

9.

Save All.

G.4.2.2 Binding the Entity Variable You have now associated an entity variable with the CustomerSDOService. To retrieve a row from the database, you will need to assign a value for the primary key. The action of assigning the value initiates the retrieval of the corresponding row. This row becomes the current row represented by the entity variable. Any changes done to the contents of this variable is the same as changing the column values of the row and these changes are automatically applied to the database in a consistent manner. 1.

Drag a Bind Entity activity and drop it just after the receiveInput activity.

2.

Rename the activity to BindCustomerId.

3.

Double-click the activity to open its properties. Select CustmerInfoEV as the entity variable and add a unique key by clicking on the + icon. For the Key Local Part, click on the browse variables icon (x) and select ns7:CustomerId from the CustomerInfoEV variable. Note that you may have a different namespace prefix other than ns7:

G-12 Using Service Data Objects (SDO)

Section G.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section G.4

4.

For the Key Value click on the Expression Builder icon and select the customer Id from the input variable.

5.

Click OK to dismiss the Specify Key window.

6.

Click OK in the Bind Entity window to complete the activity definition.

7.

Add as Assign activity directly below the BindCustomerID activity and assign the customer name from the CustomerInfoEV variable to the customerId in the input variable. Ignore the warning “Variable is not initialized” warning on this assign activity.

Using Service Data Objects (SDO) G-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

G.4.2.3 Updating the Entity Variable In this step you will update the currently retrieved customer data with order information. 1.

Create an Assign activity in the case branch which has the ApprovalRule rules activity as shown below. Name the new activity: AssignOrderInfo:

G-14 Using Service Data Objects (SDO)

Section G.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

In the Assign activity, create two copy operations. The first one is to copy the orderId from the outputVariable to LastOrderNumber in CustomerInfoEV. The second copy operation should copy the value (price * qty) from the outputVariable to Last OrderAmount in the entity variable.

3.

Save All.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section G.4

Using Service Data Objects (SDO) G-15

G.4.3 Deploying and Testing 1.

Deploy the POProcessing composite application.

2.

Run it using an order between $1000 and $5000 (po-large-iPodx30.txt test input)

3.

View the instance using the Enterprise Manager.

4.

In the Flow Trace window, click on approveLargeOrder to open the BPEL audit trail. Expand the node at the end under the callbackClient node. You should see the customerId element value is now the name of the customer that was retrieved from the database as a result of the Bind activity you added to the flow.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.

Query the CUSTOMER table in the database using your web browser through Application Express (http://localhost:8080/apex). Login as soademo/soademo.

6.

Click on Object Browser. In the Tables list select CUSTOMERS and click on Data. You should see the LAST_ORDER_NUMBER and LAST_ORDER_VALUE set to the corresponding order id and the value:

G-16 Using Service Data Objects (SDO)

Section G.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section G.4

Using Service Data Objects (SDO) G-17

H. Adding BAM Activity Sensors H.1. Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solu tions/apH-BAM To run this solution, you must have completed labs through chapter 9. Alternatively, you can do the setup in chapter 1 and use the solution from chapter 9 located at ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solu tions/ch9-JMSAdapter Oracle BAM requires the use of Internet Explorer. Since the remote hosting environment we are working in is Linux-based, Internet Explorer is not available. However, we’ll assume that you are accessing the remote hosting environment via a Windows machine. If that is the case, you’ll be able to use your own Internet Explorer software and use the IP address that has been assigned to you to access the Oracle BAM report creating facilities. BAM provides the ability for end-users to create real-time business dashboards. This lab exercise will give you a brief introduction to using BAM adapters and BAM BPEL sensors in a SOA composite. To illustrate the usage of BAM Adapter and BPEL sensors, you will modify the existing POProcessing composite to send the orders as they are received to the BAM dashboard and, for large orders, update the status in the BPEL process.

H.2. Creating Dashboards in BAM In this step, you create a data object in BAM to store data related to incoming purchase orders.

H.2.1. Defining the data object

Section H.1

1.

Start your BAM server by using the Start/Stop Weblogic Servers short-cut on the desktop.

2.

As mentioned above, to access the Oracle BAM web application, you must use Internet Explorer and only Mozilla is available on the remotely hosted environment. We’ll assume you are accessing the remote environment from a Windows machine, so use your Internet Explorer on your local machine (not on the Mozilla browser on the remote hosting environment) to go to http:[yourRemoteHostIPAddress]:7001/OracleBAM. [yourRemoteHostIPAddress] was given to you by your course instructor. For example, you might use: http://10.216.212.32:7001/OracleBAM

Adding BAM Activity Sensors H-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

If you don’t have Internet Explorer on your local machine, you can’t do this exercise.

Section H.2.1

3.

When prompted by the BAM application, login with the Username/Password of weblogic /welcome1

4.

Open the ‚Architect‛ application by clicking on the Architect button.

5.

The BAM Architect window appears. Click on the Data Objects link in the directory tree and then the Create subfolder link on the right. For the folder name, enter Training. Then, click the Create folder button.

6.

Click the Continue button. Select the Create subfolder link again. This time, name the new folder End2End-105-POProcessing. Click Create folder and click Continue when you learn that the folder has been created.

Adding BAM Activity Sensors H-2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

7.

Add a new data object by clicking on the Create Data Object link.

8. Name the data object Orders and use the Add a field link to add the following data

fields with the corresponding types and max sizes or scale: Name

Type

Max Size or Scale

Order ID

String

30

Customer ID

String

30

Product Name

String

50

Item Type

String

30

Price

Decimal

10

Quantity

Decimal

10

Status

String

50

Total

Calculated

-

Received Date

Timestamp

-

9.

Note, when you choose ‚Calculated‛, you get the option to edit the formula. In the pop-up box enter: Price * Quantity and click ‚OK‛.

10. When you have created all the fields, click the Create Data Object button.

Section H.2.1

Adding BAM Activity Sensors H-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

11. Click the Continue button once you see that the data object has been created.

You should now see the Orders data object listed on the left pane. Click on the Orders link and choose the Layout link from the left pane to see the layout.

H.2.2. Defining the BAM Dashboard

Section H.2.2

1.

Next, you’ll create a simple report based upon the data. To do that, you can close the architect window and go back to the ‚BAM Start Page‛ in your local Internet Explorer window and choose Active Studio.

2.

This will open up the report creation environment. You will create a report that everyone can view, so click on the Shared Reports tab in the upper-left portion of the window.

Adding BAM Activity Sensors H-4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

Section H.2.2

3.

To keep reports organized, you will want to create folders to put them in. Choose the Create a new folder link and name the folder Training. Next, double-click on the new Training folder and use the Create a new folder link to create a subfolder called End2End-105-POProcessing.

4.

Double-click on End2End-105-POProcessing and click the Create A New Report button. BAM provides some pre-defined layout templates for your report.

5.

Click on the one that gives you a large rectangle area at the top and 2 small square areas underneath (1st column, 3rd row).

6.

Give the report the title of PO Processing Report by clicking and typing in the title bar at the top. Notice that you are provided with many options for types of charts that you can create.

Adding BAM Activity Sensors H-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

Section H.2.2

7.

For the top (big rectangular area), choose Updating Ordered List by clicking on that type.

8.

You will need to specify the data object to assign. At the bottom of the screen, find the data object that you created by double-clicking on the Training folder and then on the End2End-105-POProcessing folder. Select the Orders data object. Then, click Next.

9.

Click the select all link and use the Arrange arrows to put the columns in a more user-friendly order, starting with the Order ID. See the ordering in the illustration below. After reordering, click Next and Finish. The fields appear in the layout.

Adding BAM Activity Sensors H-6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

10. We need to follow a similar process for the two order views. In the lower-left

panel, click on 3D Pie Chart.

11. From your Training/End2End-105-POProcessing folder, assign the Orders data object

and click Next. Choose Item Type as the Group By option, Total as the Chart Values and with Total still selected, unselect Sum and instead choose Percentage of Total as the Summary Function, then click Next.

12. Instead of clicking Finish right now, let’s change some more options by clicking on

Change View Properties. 13. Change the View Title to Percentage of Total Sales by Item Type and click OK.

14. Set the final chart (lower-right area) to 3D Bar Chart.

Section H.2.2

Adding BAM Activity Sensors H-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

15. Assign the Orders data object to it and Group By Status. Make the Chart Values as

Order ID and the summary function Count.

16. Click Next and choose Change View Properties to set the title of the view to Purchase

Orders by Status and click OK. 17. Click on the Save Report link in the upper-left pane. Then, choose the Shared

Reports button (the lower button). Drill-down into the Training/End2End-105POProcessing folder and accept the default report name PO Processing Report. Click OK. When notified that the report has been saved, click OK again.

H.3. Configure BAM Adapter on WebLogic Server In this step, you configure the WebLogic Server that is running the SOA composites. We’ll need to establish the correct settings for the BAM adapter.

H.3.1. Edit the BAM Adapter Configuration

Section H.3

1.

You need to configure the BAM adapter using the WebLogic Server administration console in order to connect to a BAM server from a SOA composite. Using your browser running in the remote environment, use the Admin Console bookmark to go to http://localhost:7001/console and login with weblogic/welcome1 as the username/password.

2.

Click on Deployments under the domain1 hierarchy.

3.

Scroll to find the OracleBamAdapter.

Adding BAM Activity Sensors H-8

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

4.

Click on the OraclebamAdapter -> Configuration (tab) -> Outbound Connection Pools (tab)

5.

Expand oracle.bam.adapter.adc.RMIConnectionFactory to find eis/bam/rmi and click on eis/bam/rmi. The properties display.

6.

Enter the host name of the BAM server, username, password and port as shown below. The values can be edited by clicking on the Property value. Make sure you press Enter after setting each value.

7.

Click the Save button to record your property changes.

8.

In a terminal window, create a BAMPlan directory as follows: mkdir /home/oracle/Middleware/Oracle_SOA1/soa/BAMPlan After editing the path as shown, save the plan Plan.xml in the new directory.

Section H.3.1

Adding BAM Activity Sensors H-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

9.

Update your deployment to reflect the changes. Go to the Deployments screen and select the checkbox for OracleBamAdapter and choose the Update button.

10. Click Finish to complete updating the deployment.

Section H.3.1

Adding BAM Activity Sensors H-10

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

H.4. Creating a BAM Connection In this step, you make a BAM connection in the JDeveloper IDE to your BAM server.

H.4.1. Make a BAM Connection You need a connection to the BAM server to view the data objects that are available to enable JDeveloper to generate appropriate WSDL files automatically.

Section H.4

1.

Open the POProcessing application in JDeveloper.

2.

Create a connection to the BAM server by right-clicking on Connections in the Application Resources navigator and choosing New Connection and BAM.

3.

In Step 1 (the Name screen), select Application Resources, accept the default name of BAMServerConnection1 and click Next.

4.

Enter the localhost for BAM Web Host and BAM Server Host.

5.

Enter the HTTP port for BAM (7001) in the HTTP Port field.

Adding BAM Activity Sensors H-11

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

For User Name, enter: weblogic. For Password, enter: welcome1.

6.

Click Next, but on the Test Connection page, do NOT click the "Test Connection" button. A bug in this version will cause problems later with deployments.

7.

Click the Finish button. In the Application Navigator, Application Resources pane, the new BAM Server connection is listed in the Connections section under the BAM node.

H.5. Adding a BAM Service Adapter In this step, you define the BAM service adapter which contains the parameters needed to communicate with BAM.

H.5.1. Adding a BAM Service Adapter You can add a BAM Service Adapter to the composite to send messages into BAM. 1.

Section H.5

Drag the BAM Adapter icon that is located under Service Adapters into the External References column in JDeveloper.

Adding BAM Activity Sensors H-12

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

4.

2.

This will automatically open the configuration wizard for the BAM Adapter.

3.

Give the service the name OrdersBAMAdapter and click Next.

Use the browse button to select the Orders data object under Training  End2End-105POProcessing and click the OK button.

Section H.5.1

Adding BAM Activity Sensors H-13

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

5.

Change the Operation to Upsert, leave the default Operation Name set at writetoBAM. Select _Order_ID as the key for the upsert operation. The Upsert operation will insert the row, if it doesn’t exist, or it will update it based upon the specified key. Check the box Enable Batching. This will allow messages to be captured even when the BAM server is not available. When the BAM server is available again, messages that were generated while the server was down will be sent.

6.

Click the Next button.

7.

If you need to, change the JNDI name to eis/bam/rmi to use RMI to send messages to BAM.

8.

Click Next. On the final step, click the Finish button.

H.5.2. Modifying the Mediator component 1.

Section H.5.2

Drag a link from the routePO mediator component to the OrdersBAMAdapter external reference that you just created. This will create a link between the mediator and the BAM Adapter.

Adding BAM Activity Sensors H-14

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

2.

Double-click on the routePO mediator to modify the configuration.

3.

Find the OrdersBAMAdapter::writetoBAM operation and click on the icon next to Transform Using. This will allow you to create a transformation map.

4.

Choose Create New Mapper File, accept the default name, and click OK.

Section H.5.2

Adding BAM Activity Sensors H-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

5.

This will open the mapper file. Drag from each field in the Purchase Order request to the corresponding field in the OrdersBAMAdapter WSDL. Note that you do not need to drag anything for the _Total and _Received_Date fields. These are either calculated or automatically populated for you in BAM.

6.

When you are finished the mapping, choose the Save All option from the File menu to save all files that were created or modified.

H.6. Testing BAM Integration with the BAM Adapter At this point, you can test using a mediator and a BAM Adapter to send messages to the BAM server. Deploy your composite to the SOA server and use Enterprise Manager.

H.6.1.Deploying the POProcessing Composite In the same manner as you have done previously, deploy your newly updated POProcessing composite. 1.

Right-click on the POProcessing project and deploy it to your server.

2.

Make sure you check the ‚Overwrite composites with the same ID‛, if you choose to use the same version number. If your deployment fails with a 401 server error, simply restart JDeveloper and try again. This is a bug that you only encounter once if you did Test connection on the BAM connection.

H.6.2. Running the application Test the composite to see the results appear in the BAM data objects and in the report. 1.

Section H.6

Once the application is deployed, you are ready to try running it.

Adding BAM Activity Sensors H-16

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

Section H.6.2

2.

Login to Enterprise Manager (http://localhost:7001/em) and select the version of the PO Processing component that you want to test.

3.

Click on the Test button for that service.

4.

Enter a small order from the test XML file at /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutorial /po/input/small_validCC.xml

5.

Copy the entire contents and paste them into the large text field in your browser:

6.

Click the Test Web Service button.

7.

The Response tab won't have any response because this is a one-way invocation with no reply or callback. However, you should see that the Test Status: Passed.

8.

In Internet Explorer on your local machine, go to BAM Architect and verify that the data was received in the data object by selecting the Orders Data Object and the Contents link. This verifies that the adapter changes were made correctly and everything is working properly.

Adding BAM Activity Sensors H-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

H.7. Adding BAM Sensors to the BPEL Process In this step, you add BPEL sensors to the existing BPEL process to detect changes in status and update the BAM data object. The row was originally inserted by the call to the BAM adapter from the mediator. This is another way that you can integrate from BPEL to BAM.

H.7.1. Create Variable Activity Sensors

Section H.7

1.

Open the BPEL process by double-clicking on the ApproveLargeOrder component.

2.

Double-click on the assignCCNumber activity to start to modify it.

3.

Select the Copy Operation tab and click on the plus (+) button to add a new copy operation.

4.

Use the expression ‘Pending Approval’ and map it to the status field of the Order outputVariable.

5.

Click OK.

Adding BAM Activity Sensors H-18

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

6.

In the Assign window, click on the Sensors tab to start the process of adding a new sensor.

7.

Use the plus (+) button to create a new activity sensor.

8.

Set the Name of the sensor to PendingApprovalActivitySensor and set the Evaluation Time to Completion.

9.

Use the plus (+) button in the Activity Variable Sensors area to add a variable.

10. Choose the outputVariable Order and click OK.

Section H.7.1

Adding BAM Activity Sensors H-19

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

11. Click OK to close the output variable screen.

12. There is no sensor action assigned to this activity sensor yet. Click OK to close the Edit

Activity Sensor window. Click OK to close the Assign window. 13. With the approveLargeOrder BPEL process open, navigate to the Sensor Actions folder

in the Structure panel. 14. Right-click on Sensor Actions and select Create > BAM Sensor Action.

15. The Create Sensor Action window appears.



Enter the name PendingApprovalSensorAction



Use the magnifying glass next to Data Object to select the Orders data object under Training/End2End-105-POProcessing.



Select Upsert as the BAM Operation,



Select _Order_ID as the key,



Modify the name of the map file to: bam/xsl/PendingApprovalSensorAction.xsl



Make sure that the JNDI setting is: eis/bam/rmi for the BAM Connection Factory JNDI.



Keep the Enable Batching box checked.



Use the plus symbol next to Map File to create a new mapping file.

Section H.7.1

Adding BAM Activity Sensors H-20

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing



Section H.7.1

Create links from the fields on the Source (left) side under tns:actionData > tns:payload > tns:variableData > tns:Data > sensor:Order to the corresponding fields on the Target (right) side in tns:_Orders1.

Adding BAM Activity Sensors H-21

16. Save All. 17. By following a similar process (changing the names mostly) that you used above to

create a PendingApprovalActivitySensor and a PendingApprovalSensorAction, create a new CallbackActivitySensor / CallbackSensorAction pair. Add this sensor to the callbackClient activity at the end of the process. This time set the Evaluation Time to Activation. Make sure you add the activity variable and perform the mapping. Remember you can only create a BAM Sensor Action from the structure panel while the BPEL process is open.

Section H.7.1

Adding BAM Activity Sensors H-22

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

18. When you are done, you can go back to the Sensors tab of the activity (callback client).

Double-click on the sensor that you want to edit (or use the pencil icon) and you will see the CallbackSensorAction associated with the CallbackActivitySensor.

H.8. Deploying and Running the Composite In this step, you re-deploy the new composite in JDeveloper and test it again using the Enterprise Manager testing function. This time, you use a large order.

H.8.1.Create Variable Activity Sensors Open the BPEL Process by double-clicking

Section H.8

1.

In JDeveloper, re-deploy the composite with a new version ID.

2.

In Enterprise Manager, click on the composite with the version number that you just deployed. Click on the Test button.

3.

Click on the Request tab to try the test again with a large order that has an invalid credit card.

Adding BAM Activity Sensors H-23

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

/home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutor ial/po/input/large_validCC.xml.

Section H.8.1

4.

Notice that the status is updated in the BAM Architect Contents display appearing in the Internet Explorer on your local machine:

5.

Test again with a large purchase order over $5000 with a valid credit card. Check that the status of that purchase order in BAM is ‚Pending Approval‛.

6.

Use the BPM Worklist application to approve the order. Notice that the status is updated to ‚approved‛.

7.

Open the report using Active Viewer to see the data. Use the Select Report button. It will update in real-time as new purchase orders are received.

Adding BAM Activity Sensors H-24

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-End-105-PO-Processing

I Integrating with Oracle B2B I

Integrating with Oracle B2B ................................................................................................... 1 I.1 Introduction....................................................................................................................... 1 I.2 Use Case ............................................................................................................................. 2 I.3 Configuring the Oracle B2B ............................................................................................ 3 Create a Document Definition ..........................................................................................................................3 I.3.1 Define the Trading Partners .................................................................................................................5 I.3.2 Create Listening Channel ......................................................................................................................5 I.3.3 Create Agreement ..................................................................................................................................6 I.4 Create composite: B2Bprocessing ................................................................................... 7 I.4.1 Create B2B Service: ReceivePO_B2B....................................................................................................8 I.4.2 Create Web Service: Send_PO ..............................................................................................................8 I.4.3 Create & Configure Mediator: Route_PO ...........................................................................................8 I.5 Testing the Process ........................................................................................................... 9

I.1

Introduction

Oracle B2B is an e-commerce gateway that enables the secure and reliable exchange of documents between an enterprise and its trading partners. Documents are XML data such as a purchase orders or invoices and are generally standard formats defined by an industry vertical. In any case, standard or not, the format of the document being exchanged must be agreed upon by the trading partners exchanging the document. B2B is a binding component of and is shipped with SOA Suite. The SOA Suite platform enables eCommerce business processes by providing the infrastructure for process orchestration, error mitigation, data translation and transformation. It addresses the issues of security, compliance, visibility, and management. The B2B component provides the means for managing the trading partners.

Section I-3

Integrating with Oracle B2B I-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

I.2

Use Case

In this exercise the focus is on the basic concepts, the components, and how they interoperate.



Oracle B2B – Manages the interactions with the remote partner: o

Document Management: Translation, Envelopes, Acknowledgments

o

Communications: Security, Transports, Messaging Services

o

Trading Partner Management: Profiles, Agreements

o

System Management: Reports, Metrics, Enterprise Manager

In this exercise Oracle B2B will read an XML file, process it and pass it onto the B2B composite.



B2B composite – Manages the interactions between Oracle B2B and the PO Composite: o

Routing, Transformation, Process Orchestration

In this exercise, this is simply a pass-through, but it illustrates the best practice for interoperability. In a typical situation: o

Inbound: this composite, based on trading partner information, would perform transformations, lookups, and process orchestration between Oracle B2B and the middleware.

o

Outbound: A companion composite would do all the above plus set the trading partner information for Oracle B2B.

I-2 Integrating with Oracle B2B

Section I.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing



PO Composite This is the existing middleware application that the eCommerce data is tying into via Oracle B2B:



Error Mitigation Composite This is out of scope for this exercise, but keep in mind that there is a need for an error mitigation framework. This is a composite to mange errors between the applications, the Trading Partners, and the middleware. There are two types of errors: In-Band and Out-of-Band:

I.3

o

In-Band: An error occurs in a process: Example: An error occurs within composite process and the appropriate action is taken.

o

Out-of-Band: an error occurs outside of process: Example: How to mitigate the Oracle B2B time out error in the middleware and/or application.

Configuring the Oracle B2B The steps are: 1.

Create a Document Definition: The Purchase Order

2.

Define the Trading Partners and assign the new partner “MarketInc” the new document

3.

Create the Host Listening Channel

4.

Create and Deploy the Agreement

Create a Document Definition To create a new Document Definition: Login to the Oracle B2B Console by selecting the B2B Administration bookmark to go to http://localhost:7001/b2b. Use weblogic/welcome1 as login credentials 1.

Select Administration at the top right of the screen. Section I-3

Integrating with Oracle B2B I-3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

2.

Select Custom, under Document Protocols in the left pane.

3.

Create a new version by selecting the New Version button at the top right.

4.

Enter Version Name: 1.0

5.

Click Save.

6.

Create a new type by selecting the New Type button at the top right.

7.

Name the document type: PurchaseOrder

8.

Click Save.

9.

Create a new definition by selecting the New Definition button an the top right.

10. Name the Document Definition: PurchaseOrder_def 11. Click Save. 12. Select Browse next to the Definition field on the Document Definition pane and choose po.xsd from ~/SOA11gFoundationTutorial/po/schemas. 13. Select Identification Type: XML 14. On the XML tab, set the Identification Expression: //*[local-name()='PurchaseOrder'] 15. On the Routing tab, set the Document Routing ID: PurchaseOrder10 16. Click Save.

I-4 Integrating with Oracle B2B

Section I.3

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

I.3.1

Define the Trading Partners To update the host and create partner MarketInc: 1.

Select Partners at the top right

2.

In the left-most pane, select the Edit Trading Parter icon (pencil) for the host trading partner MyCompany and change the Partner Name to OracleServices. Click OK.

3.

Create new trading partner using the Add New Trading Partner icon (plus sign). the Partner Name to: MarketInc and click OK.

4.

Select MarketInc in the left-most pane and then select the Documents tab.

5.

I.3.2

Set



Add (plus icon)

Custom > 1.0 > PurchaseOrder > PurchaseOrder_def



Sender box

Check



Receiver box

Un-Check

Click Save.

Create Listening Channel To create the Host Listening Channel: 1.

Select Administration in the upper-right part of the browser window.

2.

Scroll the tab list to the right and select the Listening Channel tab

3.

Select Add Channel to Trading Partner:

4.



Name

File_ListeningChannel



Protocol

Generic File-1.0

Transport Protocol Parameters tab

Section I-3

Integrating with Oracle B2B I-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

5.



Poling Interval

5



Folder Name:

/home/oracle/orclsrvs_in

Channel Attributes Tab 

Enable Channel

Radio button



Internal

Uncheck

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

6.

I.3.3

Click Save

Create Agreement Now create a new Agreement. 1.

Select Partners at the top-right area of the browser window.

2.

Select the Create New Agreement icon (plus sign) in the Agreement section at the lowerleft:

I-6 Integrating with Oracle B2B

Section I.3

3.

Click the Select Partner link in the image at the top of the screen. 

4.

Click the Select Document Definition link in the image at the top of the screen. 

I.4

Select Partner MarketInc

Select document Custom-1.0-PurchaseOrder-PurchaseOrder_def and click OK.

5.

Enter Agreement Id: OS_MI_1000

6.

Enter Name: OracleService_MarketInc_Agr

7.

Click Save.

8.

Click Validate. You will see the validation message below the agreement name on the top left of the Agreement window. For example, look for: Agreement OracleService_MarketInc_Agr is valid.

9.

Click Deploy. See the Deployment Successful message appear in a pop-up window.

Create composite: B2Bprocessing Now, create the composite that will use this agreement. When completed, it will look like this.

Section I-3

Integrating with Oracle B2B I-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

1.

I.4.1

Create B2B Service: ReceivePO_B2B 1.

I.4.2

In JDeveloper, create a new SOA application called B2Bprocssing with a project called B2Bprocessing starting with an empty composite.

Drag and drop a B2B Service to the left swim lane and enter the following values: 

Service Name: ReceivePO_B2B



B2B Integration Type: Default



Pick server connection (choose MyAppServerConnection) and click the Test B2B button. Look for the B2B server connection successful !! message.



Click Next.



Operation: Receive and click Next.



Document Definition Handling: Basic and click Next.



Document Definition: Custom, select (walk tree): PurchaseOrder_def and click Next.



Click Finish to complete the wizard sequence. The ReceivePO_B2B exposed service appears on the composite diagram.

Create Web Service: Send_PO 1.

In the Enterprise Console, select Test for the POProcessing composite. Copy the endpoint URL of the WSDL. We’ll use it for the next step. Note the service should be receivePO.wsdl. For example: http://opnpgbp8.us.oracle.co:7001/soa-infra/services/default/POProcessing/receivePO?WSDL

I.4.3

2.

Back in JDeveloper, drag and drop a Web Service to the right swim lane to create a new external reference. Name the service: Send_PO. Paste the copied WSDL URL from the previous step into the WSDL URL field. Tab and the Port Type field will be filled-in automatically.

3.

Click OK to finish creating the new web service. The Send_PO external reference is added to the composite diagram.

Create & Configure Mediator: Route_PO 1.

Drag and drop a mediator component into the Components swim lane. Call it Route_PO. Elect to Define Interface Later. Click OK.

2.

Wire the mediator to the B2B service on the left and to the PO service on the right

3.

Edit the Route_PO mediator and create a new mapper file containing a simple one-to-one transformation to map the PurchaseOrder input to the PurchaseOrder output.

4.

Save All.

I-8 Integrating with Oracle B2B

Section I.4

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

I.5

Testing the Process 1.

Deploy the B2Bprocessing project.

2.

Copy one of the sample input files supplied (files starting with MarketInc…) in the ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/input directory into your B2B input directory (/home/oracle/orclsrvs_in). You may need to create the orclsrvs_in directory first. As soon as the file lands in orclsrvs directory, it is picked up by the B2B application and is deleted from this directory.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section I-3

Integrating with Oracle B2B I-9

3.

Use the browser’s B2B Administration bookmark to go to the Oracle B2B console to view the metrics using the Reports and Metrics links on the top right.

 Review Reports – click on message Details link (plus/minus icon at left of row) to see details o Click the Wire Message link: Review details and URL o Click the Payload Storage link: Review detail and data o Click the Application Message link: Review details, Application Name, Composite Name / Version, Reference & Service  Review Metrics – If you place the a market into into the /home/oracle/orclsrvs_in directory three times, your metrics may look like this:

I-10 Integrating with Oracle B2B

Section I.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section I-3

Integrating with Oracle B2B I-11

J

Virtualize the Credit Validation Service on Oracle Service Bus

Virtualize the Credit Validation Service on Oracle Service Bus ................................................................. 1 J.1 Introduction ................................................................................................................................................. 1 J.2 Designing the Flow..................................................................................................................................... 2 J.3 Prerequisites ................................................................................................................................................ 3 J.4 Create Project and Import Resources ....................................................................................................... 3 J.5 Configure Business Service ....................................................................................................................... 6 J.6 Configure the Proxy ................................................................................................................................. 13 J.7 Configure Message Flow ......................................................................................................................... 18 J.8 Re-wire POProcessing Composite .......................................................................................................... 23 J.9 Test the end-to-end application .............................................................................................................. 24

J.1 Introduction Note: The solution for this chapter can be found in ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutions/apJ-OSB. The solution includes an OSB import file called Lab J OSB solution sbconfig.jar with the OSB configuration. You should have completed Chapter 9 or begin with the solution from Chapter 9 located at ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solutions/ch9JMSAdapter. Now that you have completed the POProcessing composite application, it’s time to think about how this application will behave once it is deployed in production. 

Are there elements embedded in our application that will change frequently?



Could these dependencies require re-deployment of the application unnecessarily, creating a disruption of service to the consumers of the POProcessing application?

If so, we should work to minimize and remove these dependencies to allow our composite to be more resilient to change. Upon inspection, the credit validation service is a good candidate to decouple from the POProcessing composite. While the interface for the credit validation service is fairly stable, the service provider may be replaced frequently. In fact, we already have been alerted that the credit validation service may be moved to another division so credit cards can be processed more efficiently. In summary, we should not have to redeploy our application every time the credit validation provider is moved or changed in some way insignificant to our own application. Being able to insulate from these types of changes will make our application more agile, robust and adaptable. Also, credit validation is a service needed by many business processes; therefore, it should be made available for enterprise-wide re-use. Re-use of IT assets helps reduce overall cost by allowing services to be shared. Section J.1

Oracle Service BusJ-1

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

J

End-2-end-105-PO-Processing

In this lab, you will register credit validation as a business service with Oracle Service Bus. You will then create a proxy service and re-wire the POProcessing composite to access this service indirectly through Oracle Service Bus. This is called service virtualization. Service virtualization provides loose-coupling and will allow the POProcessing composite to be more agile and resilient to change once put into production.

Credit Validation Service

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

J.2 Designing the Flow During this lab you will accomplish the following tasks: 

Import Resources



Configure and test a business service for validationCCService



Create a proxy and message flow to process incoming messages with data validation, reporting and error handling



Re-wire the POProcessing composite to invoke the credit validation service through Oracle Service Bus



Test the application end-to-end

Once completed, the overall message flow of the Oracle service bus proxy should look like the following picture.

Oracle Service Bus

Section J.2

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

J.3 Prerequisites This lab requires the following:



Completed solution to Chapter 9 working.



Oracle Service Bus server running



Oracle SOA Suite server running



JDeveloper up and running

J.4 Create Project and Import Resources 1.

If not already running, start the OSB Examples Server. If not already running, start your SOA server and make sure your credit card validation service is running there. To start the servers, use the Start/Stop Weblogic Server(s) short-cut on the desktop.

2.

Login to OSB Web Console using the OSB Console bookmark in the browser (http://localhost:7021/sbconsole) with username weblogic and password: weblogic

3.

Click Create button in upper-left corner of the screen to start a new session. In OSB, all changes are done in a sandbox called a session. You first create the sandbox by creating a session in the change center. After a set of related changes is done, you deploy all the changes in the session as a unit by clicking Activate in the Change Center.

Section J.3

Oracle Service BusJ-3

4.

We first need to create a project with sub folders. We could create it in the console, but instead, we will import this to illustrate how configuration can be imported into OSB. If you chose to go directly to the solution, you can import the solution in the same way. Scroll down the left pane to the bottom to find Operations and click System Administration.

5.

Click Import Resources in the Import/Export section of the left pane.

6.

Click Browse and navigate in your local filesystem to where you unzipped the lab materials. Select /home/oracle/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/solution s/apJ-OSB/Lab J OSB starting sbconfig.jar. Click Open.

7.

Click Next then Import

Oracle Service Bus

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Section J.4

8.

Click the Activate button in the upper-left corner to commit the OSB configuration change.

9.

Then click the Submit button.

10. Scroll to the bottm of the left pane. Click Project Explorer. You should see a top-level project called

Credit Services with a sub folder called BusinessServices.

11. Click on Credit Services. You should see that three sub folders have already been created for you.

These include: BusinessServices, ProxyServices and Resources.

12. Navigate to the Resources folder. Click on the Create Resources drop-down list and select Resources

from URL.

Section J.4

Oracle Service BusJ-5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

13. You will import resources from the WSDL URL of SOA Suite Server. You can simply paste the URL

to the WSDL into the URL/Path field as shown below. The precise URL to the WSDL file can be copied from the validationForCC test page in the Enterprise Manager console. Be sure to remove any version numbering. The URL will look like this. http://opnpgbp8.us.oracle.co:7001/soainfra/services/default/validationForCC/getStatusByCC?WSDL Specify the Resource Name as ValidateCredit_WSDL and make sure that the Resource Type is set to WSDL.

14. Click Next. Click Import. You now have imported the WSDL and schema needed to create the

Business Service for the credit validation service on Oracle Service Bus.

J.5 Configure Business Service A business services defines the interface and connection information for an endpoint that OSB invokes. It is similar to a composite reference. 15. Navigate to the Business Services folder. From the Create Resource drop-down list, select Business

Service.

Oracle Service Bus

Section J.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

16. On the General Configuration pane, fill-in the Service Name and Description as shown below.

Click the Browse button next to WSDL Web Service. This will bring up window to select WSDL for the business service.

Section J.5

Oracle Service BusJ-7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

17. Click on link to WSDL imported in previous step, ValidateCredit_WSDL.

18. Select the execute_pt under the Ports and then press Submit.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

19. Click Next through each of the remaining configuration screens in the wizard. If you receive an error

message indicating that validationForCC already exists, exit the wizard since it’s already been created. Make a mental note if this situation occurs as you may need to execute some troubleshooting steps later when you test your business service. Review options available to business services. Accept all of the defaults. Finally, on last screen showing all the options together in a table format, scroll down and press Save. Don’t forget this step and navigate away from this page before hitting Save or you’ll lose your changes.

Oracle Service Bus

Section J.5

20. From the Project Explorer view, click on your new business service.

21. Click on Operational Settings tab near the top of the page.

22. Check the box Enabled next to Monitoring. It may already be checked. 23. Change the aggregation interval to greater than 10 minutes. It may be set to 25 minutes so that’s

fine.

Section J.5

Oracle Service BusJ-9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Enabling monitoring will collect metrics for your service such as average response time, average TPS and number of errors. You can define SLA alerts on these metrics. The aggregation interval defines how often metrics will rollover. Generally for demos, you want to select something longer than 10 minutes, say 25 to 30 minutes. Note that all the operational settings can be set at a fine-grained service level 24. Click Update button to save your changes.

25. Activate your changes by clicking the Activate button in upper-left corner of screen.

Add a Description to document what was done. This will help you identify later in the Change Center in case you would like to undo or re-do your changes. Click Submit. You are now ready to test your first OSB business service!

Oracle Service Bus

Section J.5

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

26. In the OSB console’s Project Explorer, select the

next to your new Business Service to bring up

the Business Service Testing window.

Before proceeding, ensure you can invoke the validationforCC service is deployed on your SOA server. 27. Set the credit card number to 1234-234-1234-1234. The test XML should look like this.

1234-1234-1234-1234

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

28. Click Execute button.

29. Review the Response document for VALID. Troubleshooting Advice: Your test may fail due to a

problem with the port number in the URL endpoint for your validationForCC service. You may have experienced earlier that the business service had already been created when you tried to save it. If you experienced that, you’ll likely need to edit your validationForCC business service and change the port number to 7001 as shown below. Then, activate your changes and retest. Section J.5

Oracle Service BusJ-11

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

When the test succeeds, you’ll see this response:

Oracle Service Bus

Oracle University and Digora use only

End-2-end-105-PO-Processing

Section J.5

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

J.6 Configure the Proxy A proxy service is the OSB mediation logic that virtualizes the endpoint that OSB routes to and decouples it from the client. We will first just create a proxy service exposed to the client that just routes to the business service. Later we will add more logic in the proxy service.

31. Navigate to the ProxyServices folder. Click on Create Resources drop-down list and select Proxy

Service.

32. On General Configuration page, set Service Name to ValidateCredit. Set the Service Type to your

WSDL web service by clicking the Browse button , selecting the WSDL you just imported and choosing execute_pt under ports. Then, click on Submit.

Section J.6

Oracle Service BusJ-13

Oracle University and Digora use only

30. Click the Create button in the Change Center to start a new session.

33. Click Next through the remaining configuration screens, making note of some of the settings for

Proxy. Notice that you can configure security for your services as well as enable content and attachment streaming. Note, at this point, you are likely to see an error message that “a proxy service with the given name already exists.” This indicates that it has already been created for you. You can click Cancel to abandon the wizard sequence and skip the next step. If the proxy service didn’t already exist, you will see the Summary page. Select the Save button at the bottom of page.

34. Navigate to the newly created Proxy Service via Project Explorer.

Oracle Service Bus

Section J.6

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

35. Click on the Message Flow

icon next to ValidateCredit. This will take you to the Message Flow

editor.

Note: The following steps may not be necessary for you if the ValidateCredit proxy already existed since the routing has already been built. It will look like this:

If the route already exists as shown above, just read through the next few steps to see how it was created. Then, move on to step 43 to test the proxy. To create the routing: 36. Click on ValidateCredit icon and select Add Route. 37. Click on RouteNode1 icon and select Edit Name And Comments. Change the name to

RouteTo_validationForCC and click on Save. 38. Click on the RouteTo_validationForCC and select Edit Route.

Section J.6

Oracle Service BusJ-15

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

39. Click on Add an Action, and select Communication and then Routing.

40. Click on service link and select validationForCC and click Submit.

Oracle Service Bus

Section J.6

41. Check the checkbox Use Inbound operation for outbound. Click on Save All.

42. Click Activate on left hand side of screen to commit your changes to the session. You are now ready

to test your new Proxy! 43. Navigate to the new Proxy Service and click on the

to bring up the Test Console.

44. Executing the same test you did earlier for the business service by entering 1234-1234-1234-1234 for

CCNumber in the Payload text box. 45. Click on the Execute button. You should see output similar to when you tested your Business Service. 46. Instead of the previous steps, an alternative way to create the same proxy service is to auto generate it

from the business service. When creating the proxy service, on the General Configuration page, select Create From Existing Service and click on Browse to select the business service you created. However, the proxy so generated does not work properly in this version unless the step to enable monitoring of the business service is done after the proxy is generated. Section J.6

Oracle Service BusJ-17

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

J.7 Configure Message Flow 47. Navigate to the newly created Proxy Service via Project Explorer. 48. Click on Create to start a new session in the Change Center. 49. Click on the Message Flow

icon next to ValidateCredit. This will take you to the Message Flow

editor.

50. Notice that a Route node has already created to pass-through to the validateforCC service.

51. Note that, if the proxy service has been already created for you above, you won’t need to perform the

following steps to create the message flow. Just read through the following steps to see how the message flow was created. Start your work again at section J8. Next you will add 1 stage and 2 actions to the Message Flow. a. Validate action will validate the incoming request payload against a schema type definition and, if the validation fails, you will configure an error handler to signal the failure. Oracle Service Bus

Section J.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

b. Reporting action will track incoming messages and stream data as it arrives from the POProcessing composite.

52. Click on the envelope above ValidateCredit Select Add Pipeline Pair.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

53. Click on left Request_Pipeline and select Add Stage.

Section J.7

Oracle Service BusJ-19

54. Click on new Stage and select Edit Stage.

55. Now, we will add 2 Actions, Report and Validate. The Reporting action allows you to record any

payload elements along with key-value pairs to a database. Validate will allow us to check for valid input to credit card validation service and throw an error if invalid input message is detected. 56. Click on Add Action->Reporting->Report.

57. Fill in fields as follows:

Expression: $body KeyName: CCNumber Key Value: ./cca:creditcardStatusRequest in variable body Oracle Service Bus

Section J.7

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

58. Add Validate Action

59. Fill in fields.

XPath: ./* (dot slash star) variable: body Resource: XMLSchema_-248516241* ( Element = "creditcardStatusRequest" )

60. Click Save Button. 61. Navigate to top of message flow and click on envelope.

62. Select Add Service Error Handler. 63. Click on Error Handler

Section J.7

Oracle Service BusJ-21

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

64. Select Add Stage.

65. Click on stage and select Edit Stage.

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

66. Click on Add Action -> Reporting->Alert

67. Fill-in Alert as depicted below and click on Save All.

Oracle Service Bus

Section J.7

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

68. Activate the session in Change Center.

J.8 Re-wire POProcessing Composite Next, you'll open your POProcessing composite and fix the getCreditCardStatus reference to invoke Oracle Service Bus. 69. Open JDeveloper, if not already open. Navigate to the POProcessing application.

Double click the getCreditCardStatus reference link (highlighted above). Edit the WSDL URL field to point to your new proxy in Oracle Service Bus. For example, if you named your Proxy as recommended in the guide, the URL would be: http://localhost:7021/Credit_Services/ProxyServices/ValidateCredit?WSDL Click Tab so that the Port Type is filled-in for you.

Section J.8

Oracle Service BusJ-23

Oracle University and Digora use only

70. Double-click the composite.xml in the left pane to open the Composite editor.

71. Click OK. 72. Save All. 73. Re-deploy the POProcessing composite. You are now ready to test your end-to-end scenario with

Oracle Service Bus.

J.9 Test the end-to-end application 74. After deploying, in the Enterprise Manager console, click on the POProcessing application and then

open the Test page. 75. Click XML View. 76. In the previous chapter you submitted a small order which created an order file directly. This time

you'll create a large order which the Mediator will route to the BPEL approval process. Open the following file in a text editor: ~/SOA11gFoundationTutorial/SOA11gFoundationTutorial/po/input/po-largeiPodx30.xml Copy the entire contents and paste them into the large text field in your browser:

Oracle Service Bus

Section J.9

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

77. Click Test Web Service. 78. Check the flow trace to see that processing was completed for this latest test instance. 79. Go back to the Oracle Service Bus console. Log in if you need to. Navigate to Operations 80. Review the Message Reports.

81. Navigate to Dashboard. Have any Alerts been generated? Did you try sending your proxy bad

data? If not, try it now.

Section J.9

Oracle Service BusJ-25

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle University and Digora use only

THESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBITED

End-2-end-105-PO-Processing

Oracle Service Bus

Section J.9