Upload
truongdieu
View
217
Download
0
Embed Size (px)
Citation preview
Section 1.1 Page 1 of 41
1 Getting Started with Oracle Service Bus
1 Getting Started with Oracle Service Bus................................................................................................. 1 1.1 Prerequisites........................................................................................................................................ 1 1.2 Introduction ........................................................................................................................................ 1
1.2.1 High-level Steps..................................................................................................................................3 1.3 Setup and Deploy Composites ......................................................................................................... 4
1.3.1 URLs to access different consoles ....................................................................................................4 1.3.2 Creating Connection to Oracle WebLogic Server in JDeveloper .................................................5 1.3.3 Load SOA Composite solutions into JDeveloper...........................................................................9 1.3.4 Deploying Composites to the Application Server .......................................................................10 1.3.5 Running and Verifying the application with EM ........................................................................15 1.3.6 Getting the service description (WSDL)........................................................................................19
1.4 Configure Service Bus ..................................................................................................................... 19 1.4.1 Import Resources..............................................................................................................................19 1.4.2 Configure Business Service.............................................................................................................23 1.4.3 Config ure the Credit Card Validation Proxy ..............................................................................29 1.4.4 Configure Message Flow.................................................................................................................31
1.5 Re-wire POProcessing Composite ................................................................................................. 37 1.6 Test the end-to-end application...................................................................................................... 40
1.1 Prerequisites ���� Lab Machine Setup and Install is completed.
(See Appendix A for complete instructions to configure machine – These steps are already
completed on the Amazon EC2 instance)
���� SOA and Oracle Service Bus server instance running within Amazon EC2 instance.
1.2 Introduction
Note: The solution for this chapter can be found in /home/oracle/soa-osb/solutions/chap-1.
The solution directory includes both SOA Composite applications for JDev and the OSB configuration jar
files. The OSB solution is chap-1-solution-sbconfig.jar. The JDEV SOA Composite applications
solutions are in /home/oracle/soa-osb/solutions/chap-1/solution. If you are starting with
the solutions deploy the OSB solution followed by the SOA composites. Use OSB Console, System
Administration->Import Resources to import OSB solution configuration jar. To deploy the SOA
Composites, first open the composite applications in JDEV and then deploy by creating an
ApplicationServerConnection. You will perform end to end testing by following the instructions in
Section 1.6.
OSB 11gR1 Workshop
Section 1.2 Page 2 of 41
To develop the OSB solution from scratch you will start by importing chap-1-starting-
sbconfig.jar.
Pega Corporation has recently deployed their first major integration project into production using Oracle
SOA Suite Middleware to handle all Purchase Order Processing. As a major widget Supplier to Mega
Corporation, Pega is now positioned to help the business grow rapidly through automated order
fulfillment.
The POProcessing service was designed using a SCA Composite comprised of BPEL, Human Workflow,
Business Rules and JCA Adapters.
The new system has been quite successful and Pega IT is now looking at ways to help scale the system to
accommodate recent upturn in business. Pega has just signed on to be the widget supplier for Mega
Corporations and will handle all corporate requisitions through Pega’s supply chain and warehouse. All
Purchase Orders will be submitted through the new POProcessing system.
In order to meet these new business requirements, and become more efficient, Pega has contracted with
multiple credit card payment vendors to ensure high quality of service for POProcessing and lower costs
of each transaction to increase profit margin for handling the Mega Corporation orders.
With version two of the POProcessing composite application, it’s time to think about how this application
will accommodate the new business requirements.
• Are there elements embedded in our application that will change more 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 the credit validation service may be
provided by multiple vendors and the system should be able to add/remove vendors easily along with
giving each vendor equal business so each card transaction can be processed more efficiently.
In summary, we do not want 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 the service
to be shared.
In this lab, you will register credit validation as a Business Service with Oracle Service Bus. You then will
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 in production.
Section 1.2 Page 3 of 41
Before Virtualization with OSB
After Virtualization with OSB
1.2.1 High-level Steps
During this lab you will accomplish the following tasks:
• Deploy Composites and Test Environment
• Import Resources into OSB
• Configure and test a business service for validationForCC Composite Service
• Create proxy and message flow to process incoming messages with data validation, reporting
and error handling
• Re-wire the POProcessing composite to invoke credit validation service through Oracle Service
Bus.
OSB 11gR1 Workshop
Section 1.3 Page 4 of 41
• Test end to end application
Once completed, the overall Message Flow of the Oracle Service Bus Proxy should look like the following
picture.
1.3 Setup and Deploy Composites
1.3.1 URLs to access different consoles
Note: On the Amazon EC2 instance the SOA-OSB Server must be running. This might take up to 15
minutes for the SOA-OSB Server to start running the first time Amazon EC2 instance is launched. Please
be patient.
If the WLS Server for SOA+OSB domain (/oracle/soa/mwhome/user_projects/domains/soa_osb_domain)
does not start, Click on Start/Stop Servers on the desktop and select Start soa-osb.
You can see the tail of the log by clicking on on the desktop.
This domain is an Admin-only server with OSB+SOA.
Section 1.3 Page 5 of 41
The link for the OSB console is
http://localhost:7001/sbconsole (login with weblogic/welcome1)
The link for the EM Fusion Middle Control console is
http://localhost:7001/em (login with weblogic/welcome1)
The link for the Weblogic console is
http://localhost:7001/console (login with weblogic/welcome1)
There are already Shortcuts/Bookmarks in Firefox on your Amazon EC2 instance for the links above.
The link for SOA worklist app
http://localhost:7001/integration/worklistapp (login with weblogic/welcome1)
1.3.2 Creating Connection to Oracle WebLogic Server in JDeveloper
You must create an Application Server connection in JDeveloper to deploy the composites to the
SOA+OSB server.
Click on on the desktop to launch JDeveloper.
NOTE: The best way to launch applications on the desktop is to select the application and right-click
followed by Open (as shown below) rather than Double-Click.
You will be prompted with the Select Role dialog. Leave the default which is Default Role and Click OK.
You need to create a connection from JDeveloper to the Oracle WebLogic Server configured for Oracle
SOA Suite in order to deploy the composites from JDeveloper.
OSB 11gR1 Workshop
Section 1.3 Page 6 of 41
1. From the Application Menu, select New.
2. In the New Gallery, in the Categories tree, select General, and then Connections.
3. Select Application Server Connection
3. Click OK.
The Create Application Server Connection Type page is displayed.
Section 1.3 Page 7 of 41
4. Enter MyAppServerConnection in the Connection Name field and select WebLogic 10.3 from the
Connection Type list.
6. Click Next.
The Connection Authentication page is displayed.
7. Enter weblogic for the User Name and the password welcome1 for that administrator in the Password
field.
8. Click Next. The Configuration page displays.
9. Enter the following values:
Weblogic Hostname (Administration Server): localhost
OSB 11gR1 Workshop
Section 1.3 Page 8 of 41
Port: 7001
WLS Domain: soa_osb_domain
10. Click Next. The Test page displays.
11. Click Test Connection.
The following status should appear:
Section 1.3 Page 9 of 41
If the test is unsuccessful, ensure that Oracle WebLogic Server status is RUNNING, and retry the
test.
12. Click Next, and in the Finish page, click Finish.
13. You will see the connection in the Resource Palette
1.3.3 Load SOA Composite solutions into JDeveloper
The required composite applications are already loaded into JDeveloper on your EC2 instance. You
can skip this section.
You need to load three SOA Composites into JDeveloper
1. POProcessing
2. CreditCardValidation
3. ConsumeJMSFulfillmentApp
These applications are available under /home/oracle/soa-osb/solutions/chap-1 If not, follow the steps
below to load the composite applications into JDeveloper.
1. From the Application Menu, select Open, Browse to the application location as shown below to load
the application into JDeveloper. Let us start with the POProcessing application
OSB 11gR1 Workshop
Section 1.3 Page 10 of 41
2. Repeat Step 1 for CreditCardValidation and ConsumeJMSFulfillmentApp applications.
1.3.4 Deploying Composites to the Application Server
After you open the composite application, you can deploy it to the server
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.
3. In the project menu – right-click on the POProcessing project name - select Deploy. Make sure you
have the project menu and not the application menu in order to see this option.
4. Select Deploy to Application Server.
Section 1.3 Page 11 of 41
5. Click Next. If you redeploy the same composite multiple times then check Overwrite any existing
composites with the same revision ID if you intent to just test and hence over write the existing
deployed version of the composite. This will render existing instances Stale.
6. Click Next. On the Amazon EC2 instance, do not check ApproveTaskDetails.
OSB 11gR1 Workshop
Section 1.3 Page 12 of 41
Note: Check ApproveTaskDetails if you are trying the tutorial on your local machine and deploying
POProcessing composite the first time.
7. Select the MyAppServerConnection to deploy. If the Application Server connection does not show up in
the list, click on on the top right. This should display the MyAppServerConnection as shown
below.
Section 1.3 Page 13 of 41
8. Click Next
9. Click Finish
10. 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.
OSB 11gR1 Workshop
Section 1.3 Page 14 of 41
11. In the Deployment log, view the details of the deployment.
12. Wait for your application to be deployed
13. Repeat Steps 1 – 12 for CreditCardValidation and ConsumeJMSFulfillmentApp applications. You
select the other composites from the Application Navigator as shown below
14. You are now ready to test the composites
Section 1.3 Page 15 of 41
1.3.5 Running and Verifying 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.
15. 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 they are unpacked,
compiled, and loaded into memory.)
Login with weblogic/welcome1 (or appropriate password for your environment)
The Enterprise Manager opens to the “farm” view. You can see the status of your Server as well as
the deployed Java applications and SOA composites.
16. Select validationForCC composite from the list of composites on the main farm view or on the left
navigation bar. The composite page opens.
OSB 11gR1 Workshop
Section 1.3 Page 16 of 41
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.
17. Click Test button at the top of the screen. The Test page opens.
Section 1.3 Page 17 of 41
You can see the WSDL location, Operations list, and two tabs, Request and Response.
Scroll down to the Input Arguments section.
The first time you click on Test you might get the following error. You can ignore this error. Click on Test
again
18. 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.
OSB 11gR1 Workshop
Section 1.3 Page 18 of 41
19. Enter the data “1234-1234-1234-1234” 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.
20. 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.
21. Click on the component to drill down into the Instance Details of the component
Section 1.4 Page 19 of 41
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.
1.3.6 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.
22. Open the Test page for the composite you are interested in.
23. 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.
1.4 Configure Service Bus
1.4.1 Import Resources
1. Check to see if the SOA-OSB server is running. To do this, double click the desktop Start/Stop Servers
icon. Click the OK button in the first menu (the Start radio button should be
selected automatically). Then make sure the check box for the soa-osb server is checked,
, then click OK. If the server is already running a message like this will be
displayed: .
OSB 11gR1 Workshop
Section 1.4 Page 20 of 41
If it is not running, it will be started and a message will display indicating that.
2. Make sure your credit card validation service is running there (hint: use the EM console). See
Section 1.3 for details about deploying SOA Suite composites.
3. Log into OSB Web Console (http://localhost:7001/sbconsole) username weblogic, password:
welcome1
4. Click Create button in left hand corner of 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 are done, you deploy all the changes in the session as a unit by clicking
Activate in Change Center.
5. 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 hand pane and click
System Administration.
6. Click Import Resources (selected by default).
7. Click Browse and navigate to /home/oracle/soa-osb/solutions/chap-1 in your local file
system. Select chap-1-starting-sbconfig.jar.
Section 1.4 Page 21 of 41
8. Click Next then Import
9. Click the Activate button to commit the OSB configuration change.
10. Then click the Submit button.
Click Project Explorer then Project Folders. You should see a top level project called Credit_Services with
sub folder BusinessServices.
11. Click Create in the Change Center to start a new session to start adding the required resources.
12. Click Credit_ Services. Add ProxyServices folder and Resources folder under Credit_Services folder by
typing the folder names in the Enter New Folder Name field and pressing Add Folder. When
finished your project structure looks as depicted below.
OSB 11gR1 Workshop
Section 1.4 Page 22 of 41
13. Navigate to the Resources folder. Click on Create Resources drop-down box and select Bulk -
Resources from URL.
14. You will import resources from the WSDL URL of SOA Suite Server. You can simply paste the URL
of the WSDL into the URL/Path field as depicted below. The precise URL to the WSDL file can be
obtained from the validationForCC test page in Enterprise Manager console ( http://localhost:7001/em )
or by clicking the icon noted in the graphic below.
Be sure to remove any version numbering. It will be something like this.
http://orabpm-server:7001/soa-infra/services/default/validationForCC/getStatusByCC?WSDL
Click this to see
service WSDL.
Section 1.4 Page 23 of 41
15. 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.
1.4.2 Configure Business Service
A business service defines the interface and connection information for an endpoint OSB invokes. It is
similar to a composite reference.
16. Navigate to the BusinessServices folder. From the Create Resources drop-down, select Business
Service.
Put url here
OSB 11gR1 Workshop
Section 1.4 Page 24 of 41
17. On the General Configuration tab, fill in the Service Name and Description.
Click the Browse button. This will bring up the window to select WSDL for the Business Service.
Section 1.4 Page 25 of 41
18. Click on link to WSDL imported in previous step, ValidateCredit_WSDL.
19. Select the execute_pt under the Ports and then press Submit.
20. Click Next through each of the remaining configuration screens.
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).
OSB 11gR1 Workshop
Section 1.4 Page 26 of 41
21. From the Project Explorer view, Click on your new Business Service.
22. Click on Operational Settings Tab at top of page.
23. Check the box Enabled next to Monitoring.
Change the aggregation interval to greater than ten minutes.
Section 1.4 Page 27 of 41
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 roll over. Generally for demos, you want to
select something longer than 10 minutes, say 25 to 30 minutes.
Note all the operational settings can be set at fine-grained Service level.
24. Click Update button to save your changes.
25. Activate your changes by clicking the Activate button in left hand 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!
OSB 11gR1 Workshop
Section 1.4 Page 28 of 41
26. Select the next to your new Business Service to bring up the Test Console.
Before proceeding, ensure you can invoke the validationforCC service deployed to SOA.
27. Set the credit card number to 1234-1234-1234-1234. The test XML should look like this.
<cca:creditcardStatusRequest
xmlns:cca="http://www.globalcompany.com/ns/CCAuthorizationService">
<cca:CCNumber>1234-1234-1234-1234</cca:CCNumber>
</cca:creditcardStatusRequest>
28. Click Execute button.
Section 1.4 Page 29 of 41
29. Review the Response document for VALID, and close the test console window
1.4.3 Configure the Credit Card Validation Proxy
A proxy service is the OSB mediation logic that virtualizes the endpoints 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.
30. Click the Create button in the Change Center to start a new session.
OSB 11gR1 Workshop
Section 1.4 Page 30 of 41
31. Navigate to the ProxyServices folder. Click on Create Resources drop-down box and select Proxy
Service.
32. On General Configuration page, Service Name ValidateCredit. For the easiest way to create the
Proxy Service Routing to a Business Service follow Step 33. For the more lengthy process follow Steps
34-43.
33. On the General Configuration page, Select Create From Existing Service, Select Business Service
and click on Browse to select the business service, validationForCC, you created. Click Last and Click
Save (Don’t miss clicking Save).
Section 1.4 Page 31 of 41
34. Click Activate on left hand side of screen to commit your changes to the session. Click Submit. You
are now ready to test your new Proxy!
35. Navigate to the new Proxy Service and click on the to bring up the Test Console for the Proxy
Service. You can click on to see the Message Flow logic for the Proxy Service
36. Cut and paste the same XML you used to test the validationForCC business service, or enter the credit
card number of “1234-1234-1234-1234 into the Payload text box.
37. Click on the Execute button. You should see output similar to when you tested your Business Service
directly. Close the “Proxy Service Testing” window when complete.
1.4.4 Configure Message Flow.
38. Navigate to the newly created Proxy Service via Project Explorer.
39. Click on Create to start a new session in the Change Center.
40. Click on the Message Flow icon next to ValidateCredit. This will take you to the Message Flow
editor.
41. Notice a Route node has already been created to pass-through to the validateforCC business service.
OSB 11gR1 Workshop
Section 1.4 Page 32 of 41
42. Next you will add one stage (Stage allows grouping of related actions) with two 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
b. Report action will track incoming messages and stream data as it arrives from the POProcessing
composite.
43. Click on the envelope above ValidateCredit Select Add Pipeline Pair.
Section 1.4 Page 33 of 41
44. Click on left Request_Pipeline and select Add Stage.
45. Click on new Stage and select Edit Stage.
46. Now we will add 2 Actions, Report and Validate. The Report action allows you to record any
payload elements along with key-value pairs to a database.
Validate action will allow us to check for valid input to credit card validation service and throw an
error if invalid input message is detected.
47. Click on Add Action->Reporting->Report.
OSB 11gR1 Workshop
Section 1.4 Page 34 of 41
You will see the Report action as below
48. Fill in fields as follows:
Expression: $body (Click on <Expression>, Enter $body in text area, Click Save)
Click Add a key:
KeyName: CCNumber
Key Value: ./cca:creditcardStatusRequest/cca:CCNumber
To specify the Key Value, Click <XPath>
Either cut paste the above XPATH value into the text area OR select Variable Structures on the
left bottom. Select body from Drop Down, Expand $body – execute (request) and select CCNumber (as
shown in the figure below)
Section 1.4 Page 35 of 41
The Property Inspector field will be populated with the XPath as shown below. Click on Copy Property
to copy the XPath automatically into the text area above. (Make sure the cursor is in the text area
before you click Copy Property for the copy to work)
Click Save
In the in variable field type body and Click Save
49. Add Validate Action – Click on Stage icon and Select Edit Stage, Add an Action – Message
Processing - Validate
OSB 11gR1 Workshop
Section 1.4 Page 36 of 41
50. Fill in fields.
XPath: ./* (dot slash star)
variable: body
Resource: XMLSchema_-1537259875* ( Element = "creditcardStatusRequest" )
Note: the schema resource name will not match exactly as the name specified above as the name includes
hash code, which is generated based on the URL
51. Click Save Button.
52. Navigate to top of message flow and click on envelope.
53. Select Add Service Error Handler.
54. Click on Error Handler
55. Select Add Stage.
Section 1.5 Page 37 of 41
56. Click on stage and select Edit Stage.
57. Click on Add Action -> Reporting->Alert
58. Configure the Alert as depicted below and click on Save All.
59. Activate the session in Change Center.
1.5 Re-wire POProcessing Composite Next you'll open your POProcessing composite and fix the getCreditCardStatus reference to invoke
Oracle Service Bus.
60. Open JDeveloper if not already open. Navigate to the POProcessing application.
61. Double-click the composite.xml within “SOA_Content” folder in left hand pane open the
Composite editor.
OSB 11gR1 Workshop
Section 1.5 Page 38 of 41
62. Double click the getCreditCardStatus reference link. In the Update Reference dialog click the icon
next to the WSDL URL field. In the SOA Resource Browser select Resource Palette from the drop
down. Expand the IDE Connections tree to select the ValidateCredit Proxy Service from OSB as shown
below. Alternatively, you can also create a WSIL Connection to OSB (http://orabpm-
server:7001/sbinspection.wsil) and browse the Proxy Service.
Section 1.5 Page 39 of 41
Click OK. This will populate the WSDL URL pointing to the OSB ValidateCredit Proxy Service
63. Click OK
64. Save the composite.xml and Re-deploy the POProcessing Composite. To keep things simple, be sure
to overwrite any existing composites of the same version, as shown here. Also, do not forget to leave
the ADF Task Flow un-selected.
OSB 11gR1 Workshop
Section 1.6 Page 40 of 41
You are now ready to test your end-to-end scenario with Oracle Service Bus.
1.6 Test the end-to-end application 65. After deploying, in the EM console, click on the POProcessing application and then open the Test
page. You might get the following error when navigating in the Enterprise Manager FWM Control.
You can ignore this error and simply repeat the action again
66. Click XML View.
67. Create a large order which the Mediator will route to the BPEL approval process.
Open the following file in a text editor:
Section 1.6 Page 41 of 41
/home/oracle/soa-osb/input/po-large-iPodx30.txt
Copy the entire contents and paste them into the large text field in your browser:
68. Click Test Web Service.
69. Navigate back to the Oracle Service Bus console. Log in. Navigate to Operations
70. Review the Message Reports. You will see the report as shown below