Sie sind auf Seite 1von 47

Oracle SOA Suite 10.1.

3 Hands-On Workshop BPEL and ESB


CREATE THE PERMIT APPLICATION BPEL PROCESS................................ 2 Create JDeveloper BPEL Project............................................................................... 2 Import XSD Files ........................................................................................................ 4 Assign the BPEL Instance/Reference ID..................................................................... 9 Add Background Check............................................................................................. 19 Add ESB Data Service .............................................................................................. 29

Create the Permit Application BPEL Process


This lab will build out the BPEL process to handle permit application requests. This process will utilize the ESB BackgroundCheckSOAP and ESB PermitDBOut services.

Create a BPEL Project


1. First a JDeveloper BPEL project needs to be created. Right-click on the SOAWorkshop application workspace and select New project

Figure 1

2. In the New Gallery window, select BPEL Process Project and click the OK button.

Figure 2

3. Name the new BPEL process PermitProcess (no spaces in the name). Make sure the Template Synchronous BPEL Process is selected. Click Finish.

Figure 3

4. JDeveloper should now show an empty BPEL process as shown in the following diagram.

Figure 4

Import XSD Files


5. Next, we will import XML Schemas (XSD) that include object definitions for our Permit Application. The XSD includes definitions for the Permit Application which will be defined as the input to the BPEL process. The XSD also includes a response object that will be configured. Select the Schemas folder in the Structane pane located at the lower-left corner of JDeveloper. Then right-click.to select the Import Schema option.

Figure 5

6. In the Import Schema window, click the flashlight icon.

Figure 6

7. Select the PermitApplicationCanonical.xsd file in the /home/oracle/MyFiles/support directory. Click Open and then OK.

Figure 7

8. Now the definitions of the PermitApplicationCanonical.xsd file can be referenced in the BPEL process. You should see the PermitApplicationCanonical.xsd in the Structure pane.

Figure 8

9. Next, the inbound request object and the response object for the BPEL process needs to be assigned to structures defined in the PermitApplicationCanonical.xsd schema. By default when a BPEL process is created, these structures are defined as simple string types. In the Structure pane expand the tree for Message Types > Process WSDL as show below. Select the payload element for PermitProcessRequestMessage and select the edit pencil icon.

Figure 9

10. In the Edit Message Part window, select the flashlight icon.

Figure 10

11. In the Type Chooser dialog select the PermitApplication element under the Project Schema Files PermitApplicationCanonical.xsd path. Click OK twice.

Figure 11

12. Next, the XSD structure for the BPEL response will be defined. In the Structure pane of JDeveloper, select the payload element under the PermitProcessResponseMessage and select the pencil icon.

Figure 12

13. In the Edit Message Part window, select the flashlight icon.

Figure 13

14. In the Type Chooser dialog select the PermitApplicationResponse element under the Project Schema Files PermitApplicationCanonical.xsd path. Click OK twice.

Figure 14

15. Save your work by selecting the Save All icon

on the Toolbar.

Assign the BPEL Instance/Reference ID


16. Create an assignment in the BPEL process to place values into the BPEL response object. In the BPEL flow drag an Assign activity from Components Process Activities and drop it below the receiveInput activity.

Figure 15

17. Your BPEL process should look like the following. Double-click on the Assign_1 activity.

Figure 16

18. Click on the General tab and specify the name as AssignPermitIDAndReply.

Figure 17

19. Click on the Copy Operation tab and click the Create option. Select the Copy Operation from the pop-up list.

Figure 18

20. In the Create Copy Operation dialog select the Expression Type: in the From portion of the window (left side). Select the icon.

Figure 19

21. In the Expression Builder window select the BPEL Xpath Extension Functions from the Functions list. Select the getInstanceId function and click the Insert Into Expression button. Click OK.

Figure 20

22. In the To section of the Create Copy Operation window make sure the Variable Type: is chosen and then select the Variables Process Variables outputVariable payload ns1:PermitApplicationResponse ns1:ReferenceID element. Click OK.

Figure 21

23. Next, a copy operation will be defined for the StatusCode element in the response. For this simple scenario well just assign a value of 0. In the Assign window, select the Copy Operation again.

Figure 22

24. In the Create Copy Operation window select Expression Type: for the From variable. Enter 0 as the expression string as indicated below. For the To Variable, select StatusCode node as indicated in the diagram below. Click OK.

Figure 23

25. The last copy operation will assign the BPEL instance id to the PermitID variable defined in the PermitApplication structure. Create another copy operation following steps 20 and 21. This time map the value to Variables Process Variables inputVariable payload ns1:PermitApplication ns1:PermitID. Click OK.

Figure 24

26. Your Assign activity should now have the following 3 copy operations. Click OK.

Figure 25

27. Compile the BPEL process to make sure there are no errors. Click the Rebuild icon in the top center of the JDeveloper screen. This will compile the BPEL process and you can look at the log window for any errors. If the BPEL process was built correctly, you should see a message like the following Successful compilation: 0 errors, 0 warnings.

Figure 26

28. The BPEL process will now be deployed to the application server to validate that it runs correctly with the current logic defined. In the JDeveloper Applications window right-click on the SOAWorkshop PermitProcess project and select Deploy Local_IntegrationServer Deploy to default domain. The BPEL process will now be deployed to the application server.

Figure 27

If the Deployment Properties window pops-up just select the OK button. (For first time deployment this will not display). We will ALWAYS deploy Version 1.0 for this lab.

Figure 28

If deployment ran successfully, you should see in the Apache Ant Log window a message like the following indicating BUILD SUCCESSFUL.

Figure 29

29. Log on to the BPEL Control window to test the process. Double click on the Desktop

Icon

or go to the following URL: http://localhost:8888/BPELConsole (This URL is already in the browser Links bar)

You will be prompted for a username and password. Enter oc4jadmin and welcome1 respectively.

Figure 30

30. The PermitProcess process should be shown in the left hand list of BPEL processes under Deployed BPEL Processes.

Figure 31

31. Click on the PermitProcess link in the Deployed BPEL Processes column. You should now be presented with the Initiating a test instance page. Enter some values for some of the parameters like below. You dont need to specify values for PermitID and WorkflowID as they are assigned in the actual BPEL process. Click the Post XML Message button to invoke the process.

32. After submitting the sample data you should see output similar to the following. This shows the reply from the BPEL process.(Notice that the StatusCode has a value of 0 (which we specified in the assign activity) and the ReferenceID has value of 270001 (which should be the BPEL instance ID)). Your ReferenceID will vary. 270001 is only an example.

Figure 32

We can see by selecting the Instances tab of the BPEL Console that 270001 is the value of the BPEL instance id. This value will vary based on the current Instance ID in the BPEL system.

Figure 33

Add Background Check


33. Back in JDeveloper a background check service will be added to the BPEL process flow. Right-click in the Services swimlane on ether side of the canvas. From the popup window, select Create Partner Link

Figure 34

34. In the Create Partner Link dialog specify BackgroundCheckService (no spaces) as the partner link name. Now click on the Service Explorer (flash light icon) to locate the BackgroundCheckSOAP Service we defined in the previous ESB lab:

Figure 35

In the Service Explorer dialog navigate down through Registered ESB Services Local_IntegrationServer PermitData and select BackgroundCheckSOAP. Click OK.

Figure 36

Configure your Partner Role as indicated in the following diagram. Click OK.

Figure 37

35. Next, an Invoke activity will be added to the BPEL process to invoke the BackgroundCheckService. Drag an Invoke activity from the Components Process Activities to the BPEL canvas and place it below the replyOutput activity.

Figure 38

36. Click on the arrow icon to the right of the Invoke_1 activity and drag it on top of the BackgroundCheckService. The Edit Invoke dialog pop-up appears.

Figure 39

37. Specify the name of this activity as InvokeBackgroundCheckService.

Figure 40

38. Next, click on the magic wand icon to the right of the Input Variable: field. The Create Variable pop-up dialog should appear. This window automatically creates a BPEL variable that we will use to pass data to the background check service. Accept the default variable name. Click OK.

Figure 41

39. Click on the magic wand icon to the right of the Output Variable: field. This creates a BPEL variable for storing the reply from the background check service. Click OK.

40. The Edit Invoke dialog should now look like the following. Click OK.

Figure 42

Click the Green Checkmark on the Canvas Toolbar. This validates the process.

41. The BPEL process should now look like the following. Notice the yellow flag next to the InvokeBackgroundCheckService activity. This flag exists because we have not yet assigned values to the BPEL variables used in invoking the background service.

Figure 43

42. Drag an Assign activity above InvokeBackgroundCheckService.

Figure 44

43. Double-click on the assign activity and click the General tab. Specify a name of AssignBackgroundCheck.

Figure 45

44. Click on the Copy Operation tab. Click the Create option and select Copy Operation from the pop-up list.

Figure 46

45. The Create Copy Operation window appears. For the From Variable select the Variables Process Variables inputVariable payload ns1:PermitApplication ns1:Applicant node. For the To Variable select the Variables Process Variables InvokeBackgroundCheckService_checkApplicant_InputVariable payload ns1:Applicant node. Click OK twice.

Figure 47

46. Add an Assign activity after the InvokeBackgroundCheckService to handle the reply message from the background check service. From the Components Process Activities list drag an Assign activity to below the InvokeBackgroundCheckService activity.

Figure 48

47. Double click the Assign_1 activity. Click on the General tab and enter AssignBackgroundCheckReply in the Name: field.

48. Click on the Copy Operation tab. Create a copy operation as indicated in the following diagram. The From variable is Variables Process Variables InvokeBackgroundCheckService_checkApplicant_OutputVariable ns3:BackgroundCheck ns3:Status. The To variable is Variables Process Variables ns1:PermitApplication ns1:BackgroundCheck inputVariable ns1:Status.

payload

payload

Figure 49

Click OK.

49. Create a second copy operation like the following. The From variable is Variables Process Variables InvokeBackgroundCheckService_checkApplicant_OutputVariable ns3:BackgroundCheck ns3:FailureReason. The To variable is Variables Process Variables ns1:PermitApplication ns1:BackgroundCheck

payload

inputVariable payload ns1:FailureReason.

Figure 50

Click OK twice.

Add an ESB Data Service


50. Now well add logic to the BPEL process to invoke the ESB data service. Right-click on ether of the two Services swimlanes and select Create Partner Link.

Figure 51

51. Name the partner link PermitDataService. Click on the flashlight icon to select a service.

Figure 52

52. In the Service Explorer dialog select the Registered ESB Services Local_IntegrationServer PermitData PermitData_RS node. Click OK.

Figure 53

53. In the Create Partner Link window make sure the entry for Partner Role is as indicated in the diagram below. Click OK.

Figure 54

54. Drag an Invoke activity to the BPEL canvas below the AssignBackgroundCheckReply activity.

Figure 55

55. Drag the arrow icon on the right side of the Invoke activity and drop it onto the PermitDataService.

Figure 56

56. In the General tab name the Invoke activity InvokePermitDataService. Since this is a one-way operation you will only need to define a BPEL variable for the Input variable.

Figure 57

57. Click the magic wand icon to the right of the Input Variable: text field. Name the variable InvokePermitDataServiceInput and click OK. In the Edit Invoke window click OK.

Figure 58

58. Drag an Assign activity above the InvokePermitDataService.

Figure 59

59. Double click the Assign_1 activity. Select the General tab and specify the name as AssignPermitDataService.

60. Select the Copy Operation tab. Create a copy operation as defined in the following diagram. The From variable is Variables Process payload ns1:PermitApplication. Variables inputVariable

The To variable is Variables Process Variables InvokePermitDataServiceInput > PermitApplication > ns1:PermitApplication.

Figure 60

Click OK twice. 61. Drag and drop a Switch activity from the Components below the AssignPermitDataService Assign activity. Process Activities palette

Figure 61

62. Expand the Switch via the + and click on the green checkmark icon to create the condition for the case process flow.

Figure 62

63. When the Condition Expression dialog comes up click the green checkmark icon again to bring up the Expression Builder.

Figure 63

64. Navigate in the BPEL Variables pane to the InvokeBackgroundCheckService_checkApplicant_OutputVariable payload ns3:BackgroundCheck ns3:Status element. Click the Insert into Expression button and add = Pass to the end of the expression. Your completed expression should look like:

Figure 64

Click OK and then click anywhere in the BPEL diagram to close the small expression window. 65. Drag and drop an Assign activity into the <case> flow

Figure 65

66. Double click on the Assign and name the activity APPROVE_REJECT via the General tab. The select the Copy tab and click on Create Copy Operation. On the From side select an Expression for the Type: and type APPROVE as the expression source. On the To side select Variables Process Variables InvokePermitDataServiceInput PermitApplication ns1:PermitApplication ns1:Approval ns1:Outcome as the target.

Figure 66

Click OK twice.

67. Drag and drop an Empty activity into the <otherwise> flow.

Figure 66

Deploy the BPEL process. In the JDeveloper Applications window right-click on the BPEL project and select Deploy > Local_IntegrationServer > Deploy to default domain.

Figure 67

When the Deployment Properties window pops-up just select the OK button. (For first time deployment this will not display). We will ALWAYS deploy Version 1.0 for this lab.

Figure 68

E) Test the Entire Flow


Select Permit Application from the browser Fast Links Menu and Open in a new tab or go to http://localhost:8888/PermitDemoUI/faces/main.jsp. This is the first screen of the JSP application. Click on the Click here to apply for permit link.

In the next screen, fill out data like the example below. Select the Submit button.

A confirmation screen will be shown. Select the Confirm button if you would like to submit the data to BPEL else select the Edit button to edit your data.

If you confirmed the data, you should get a screen like the following. Notice the reference number indicated in the message (in this example the reference number is 270002, yours will vary). This is the BPEL process instance id that was returned from BPEL.

Got to the BPEL Console http://localhost:8888/BPELConsole. Log in as: oc4jadmin/welcome1 if required. Click on the Instances tab. You see that the top instance is completed.

Now, in the ESB Console (http://localhost:8888/esb/ select the Instances Icon (looks like a notepad) and you will see a new ESB flow instance was created (you can click on the green Go icon in the Search section to refresh). The ESB instance ID is the same as the BPEL instance id.

Finally, you can use JDeveloper to examine the database tables to see the new information that has been added. Select the Connections Navigator tab. Open up the Database soademo soademo Tables folder. Double-click on either the APPLICANTS or PERMITS table. Select the Data tab at the bottom of the table view. Notice the new rows that have been added.

Now well enter data that will force the BackgroundCheck to Fail and consequently no JMS message will be sent from the ESB service (i.e. specify a social security number that starts with 9).

Open a browser to http://localhost:8888/PermitDemoUI/faces/main.jsp. This is the first screen of the JSP application. Click on the Click here to apply for permit link.

In the next screen, fill out data like the following. Notice the 9 leading the SSN. Select the Submit button.

Go back to the BPEL Console. You will now see that a new BPEL instance has run and is complete.

Finally, using the ESB Console notice that during this run the JMS destination was not invoked. The Filter Rule criteria was NOT met since the outcome was not APPROVE.