J Virtualize The Credit Validation Service On Oracle Service Bus
J Virtualize The Credit Validation Service On Oracle Service Bus
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/ch9-
JMSAdapter.
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.
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.
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
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.
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.
8. Click the Activate button in the upper-left corner to commit the OSB configuration change.
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.
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/soa-
infra/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.
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.
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.
18. Select the execute_pt under the Ports and then press Submit.
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.
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.
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.
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!
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.
<cca:creditcardStatusRequest
xmlns:cca="http://www.globalcompany.com/ns/CCAuthorizationService">
<cca:CCNumber>1234-1234-1234-1234</cca:CCNumber>
</cca:creditcardStatusRequest>
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.
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.
30. Click the Create button in the Change Center to start a new session.
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.
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.
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.
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.
39. Click on Add an Action, and select Communication and then Routing.
40. Click on service link and select validationForCC and click Submit.
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
End-2-end-105-PO-Processing
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.
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.
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.
Expression: $body
KeyName: CCNumber
Key Value: ./cca:creditcardStatusRequest in variable body
Oracle Service Bus Section J.7
End-2-end-105-PO-Processing
70. Double-click the composite.xml in the left pane to open the Composite editor.
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.
73. Re-deploy the POProcessing composite. You are now ready to test your end-to-end scenario with
Oracle Service Bus.
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-large-
iPodx30.xml
Copy the entire contents and paste them into the large text field in your browser:
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
81. Navigate to Dashboard. Have any Alerts been generated? Did you try sending your proxy bad
data? If not, try it now.