To log into Oracle Service Bus Console, we have to open a web browser and access the following URL: http://host_name:port/sbconsole, where host_name is the name of the host on which OSB is installed and port is a number that is set during the installation process. We log in as user weblogic. The Oracle Service Bus Console opens, as shown in the following screenshot:
The Dashboard page is opened by default, displaying information about alerts. We will show how to defne and monitor alerts later in this article. In the upper-left corner, we can see the Change Center.
Change Center is key to making confguration changes in OSB. Before making any changes, we have to create a new session by clicking the Create button. Then, we are able to make different changes without disrupting existing services. When fnished, we activate all changes by clicking Activate. If we want to roll back the changes, we can click the Discard button. We can also view all changes before activating them and write a comment.
Creating a project and importing resources from OSR
First, we have to create a new session, by clicking the Create button in the Change Center. Next, we will create a new project. OSB uses projects to allow logical grouping of resources and to better organize related parts of large development projects. We click on the Project Explorer link in the main menu. In the Projects page, we enter the name of the project (TravelApproval) and click Add Project. The new project is now shown in the projects list on the left side in the Project Explorer. We click on the project.
Next, we add folders to the project, as we want to group resources by type. To create a folder, we enter the folder name in the Enter New Folder Name field and click Add folder. We add six folders: BusinessServices, ProxyServices, WSDL, XSD, XSLT, and AlertDestinations.
Next, we have to create resources. We will show how to import service and all related resources from the UDDI registry. Before creating a connection to the UDDI registry, we will activate the current session. First, we review all changes. We click the View Changes link in the Change Center. We can see the list of all changes in the current session. We can also undo changes by clicking the undo link in the last column.
Now, we activate the session by clicking on the Activate button. The Activate Session page opens. We can add a description to the session and click Submit.
Now, all changes made are activated.
Creating connection to Oracle Service Registry
First, we start a new session in the Change Center. Then we click on the System Administration link in the main menu. We click on the UDDI Registries and then Add registry on the right side of the page. We enter connection parameters and click Save.
Now, the registry is listed in the UDDI Registries list, as shown next:
We can optionally activate a current session. In that case, we have to create a new session before importing resources from UDDI.
Importing resources from Oracle Service Registry
We click on the Import from UDDI link on the left-hand side. As there is only one connection to the registry, this connection is selected by default. First, we have to select the Business Entity. We select Packt Publishing. Then we click on the Search button to display all services of the selected business entity. In the next screenshot, we can see that currently there is only one service published. We select the service and click Next.
In the second step, we select the project and folder, where we want to save the resources. We select the TravelApproval project and the folder BusinessServices and click Next.
On the fnal screen, we just click the Import button. Now we can see that a business service, a WSDL, and three XSD resources have been created.
All resources have been created automatically, as we imported a service from the UDDI registry. If we create resources by hand, we frst have to create an XML Schema in WSDL resources, and then the Business service.
As all resources have been saved to the BusinessServices folder, we have to move them to appropriate folders based on their type. We go back to the Project Explorer and click on the BusinessServices folder in the TravelApproval project. We can see all imported resources in the Resources list at the bottom of the page.
We can move resources by clicking on the Move Resource icon and then selecting the target folder. We move the WSDL resource to the WSDL folder and the XML Schemas to the XSD folder.
Configuring a business service
If we want to monitor service metrics, such as average response time, number of messages, and number of errors, we have to enable monitoring of the business service. We will also show how to improve performances by enabling service result caching, which is a new feature in OSB 11g PS2.
Enabling service result caching
OSB supports service result caching through the use of Oracle Coherence, which is an in-memory data grid solution. In this way, we can dramatically improve performances if the response of the business service is relatively static. To enable the use of service result caching globally, we have to open the Operations | Global Settings and set Enable Result Caching to true..
In the Project Explorer, we click on our Business service. On the Confguration Details tab, we will enable service result caching. We scroll-down and edit the Message Handling Confguration. Then we expand the Advanced Settings. We select the Result Caching checkbox. Next, we have to specify the cache token, which uniquely identifes a single cache result. This is usually an ID field. In our simplifed example, we do not have an ID field; therefore, we will use the employee last name for testing purposes. We enter the following cache token expression: $body/emp:employee/LastName. Then we set the expiration time to 20 minutes.
Then, we click Next and Save.
Now, if the business service locates cached results through a cache key, it returns those cached results to the client instead of invoking the external service. If the result is not cached, the business service invokes the external service, returns the result to the client, and stores the result in cache.
Service result caching works only when the business service is invoked from a proxy service.
Enabling service monitoring
Again, we click on our Business service and then click on the Operational Settings tab. We select the Enabled checkbox next to the Monitoring and set the Aggregation Interval to 20 minutes. The aggregation interval is the sliding window of time over which metrics are computed. We can also defne SLA alerts which are based on these metrics.
We click Update to save the changes. Then, we activate the changes by clicking on the Activate button in the Change Center.
Testing a business service
After activating the changes, we can test the business service using the Test Console. To open the console, we select the BusinessServices folder and then click on the bug icon next to the Business service.
The Test Console opens. We set the XML payload and click the Execute button.
After executing the Business service, we can see the response message as shown in the next screenshot:
Creating an Alert destination
Before creating a proxy service, we will create an Alert Destination resource, which will be later used for sending e-mail alerts to the administrator. Remember, that we have already created the AlertDestinations folder.
To be able to send e-mail alerts, we have to frst confgure the SMTP server on the System Administration page.
To create an Alert destination, we navigate to the AlertDestinations folder and then select the Alert Destination from the Create Resource drop-down. We set the name to Administrator and add an e-mail recipient by clicking the Add button. We enter the recipient e-mail address (we can add more recipients) and select the SMTP server.
Then we click Save twice.
Creating a proxy service
Although at the frst sight it might seem redundant, using a proxy service instead of calling the original business service directly has several advantages. If we add a proxy service between the service consumer and the original service, we gain transparency. Through OSB, we can monitor and supervise the service and control the inbound and outbound messages. This becomes important when changes happen. For example, when a service interface or the payload changes, the proxy service can mask the changes to all service consumers that have not yet been upgraded to use the new version. This is, however, not the only beneft. A proxy service can enable authentication and authorization when accessing a service. It can provide a means to monitor service SLAs, and much more. Therefore, it often makes sense to consider using proxy services.
We will show an example to demonstrate the capabilities of proxy services. We will create a proxy service, which will contain the message processing logic and will be used to decouple service clients from the service provider. Our proxy service will validate the request against the corresponding XML schema. It will also perform error handling and alert the service administrator of any problems with the service execution.
First, we start a new session (if there is no active session) by clicking the Create button in the Change Center. Then we navigate to the ProxyServices folder in the Project Explorer. We click on the Create Resources drop-down and select Proxy Service.
The General Confguration page opens. We set the name of the proxy service to EmployeeTravelStatusServiceProxy. We also have to defne the interface of the service. We select the Business service, as we want the proxy service to use the same interface as the business service. We click the Browse button and select the EmployeeTravelStatusService business service.
Then we click Next. On the Transport Configuration screen, we can change the transport Protocol and Endpoint URI.
We use the defaults values and click Next. The HTTP Transport Confguration screen opens. We click Next on the remaining confguration screens. On the Summary page, we click the Save button at the bottom of the page.