You are on page 1of 26

End-2-end-105-PO-Processing

J Virtualize the Credit Validation Service


on Oracle Service Bus

J 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/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.

Section J.1 Oracle Service BusJ-1


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

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


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


End-2-end-105-PO-Processing

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 Section J.4


End-2-end-105-PO-Processing

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


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/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.

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


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


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.

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


End-2-end-105-PO-Processing

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


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


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.

<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.

Section J.5 Oracle Service BusJ-11


End-2-end-105-PO-Processing

When the test succeeds, you’ll see this response:

Oracle Service Bus Section J.5


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.
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.

Section J.6 Oracle Service BusJ-13


End-2-end-105-PO-Processing

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


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


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


End-2-end-105-PO-Processing

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

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


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.

53. Click on left Request_Pipeline and select Add Stage.

Section J.7 Oracle Service BusJ-19


End-2-end-105-PO-Processing

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
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


End-2-end-105-PO-Processing

64. Select Add Stage.

65. Click on stage and select Edit Stage.

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


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.

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.

Section J.8 Oracle Service BusJ-23


End-2-end-105-PO-Processing

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-large-
iPodx30.xml
Copy the entire contents and paste them into the large text field in your browser:

Oracle Service Bus Section J.9


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


End-2-end-105-PO-Processing

Oracle Service Bus Section J.9

You might also like