Adding a service to Oracle Service Bus
By Chris Tomkins on Nov 14, 2007
Note: This post was first published before Oracle merged with BEA when the Oracle Service Bus product was known as AquaLogic Service Bus, hence the occasional reference to BEA and AquaLogic Service Bus.
A common first task for people who have installed Oracle Service Bus is to add an existing service to the bus - after all what is the point of a service bus without any services! In the remainder of this post I'll explain the basic process for doing this as it will give you a good introduction to a number of Oracle Service Bus concepts, which I am sure I will talk about in more detail in future posts.
First things first, you need to start the server by clicking on the Start Server for AquaLogic Service Bus Domain Windows shortcut under All Programs>BEA Products>User Projects>Name of your domain (on other platforms run the startWebLogic script from the corresponding directory on your filesystem).
Next you need to launch the service bus console which you can do by pointing your web browser at http://localhost:7001/sbconsole (note the server name and port may differ if you have changed the defaults during the install process):
In order to start making any changes to the service bus you need to use the Change Center to activate a session (a topic for another blog post I'm sure, but basically it allows you to make a set of changes, apply them when complete, and roll them back at a later date if you so wish). To do this, just click the Create button in the top left of the screen.
Next you need to create a project to group our resources together, so click on Project Explorer in the left hand navigation, enter a new project name where prompted, e.g. Adding a service to Oracle Service Bus, and click the Add Project button. You should end up with a screen that looks like:
Now you have a project, you can give it a meaningful description and can create a set of folders to organise the artifacts we are about to create. You can add the description by clicking the project you have just created and clicking on Edit Description, entering some text and then clicking Submit Description. To add the folders, enter the folder name where prompted and then click Add Folder. For now, create 2 folders called: WSDL and Business Services. You should end up with a screen that looks like:
At this point it is a good idea to complete the Change Center session as it means you can easily return to this point if you do something wrong at a later stage. To do this, click the green Activate button in Change Center and enter some descriptive text giving an overview of what you have done (this makes it easy to identify the changes later):
Then click Submit.
To continue to make changes you need to create another session, so do this now by clicking Create in the Change Center again.
Next, you need to import a WSDL, which describes your existing service, into the WSDL folder in your project. I have selected to import an existing WSDL for a free CurrencyConverter web service from WebServiceX which allows you to input two different currencies and find the conversion rate but you can choose any service you wish. To do this navigate to the WSDL folder via the Project Explorer, click on the Create Resource drop down box in the right hand section and select the Resources from URL option. Complete the screen that appears as follows:
Click Next, confirm the information is correct and then click Import.
Now you have the WSDL imported, it is time to create a business service - a representation of the service including both its interface and how to connect to it, which can then be re-used by other Oracle Service Bus services. To do this, use the Project Explorer to navigate to the Business Services folder you created earlier in the Adding a service to Oracle Service Bus project.
From the Create Resource drop down, choose to create a Business Service.
Enter a Service Name, e.g. CurrencyConverterBS and a description and then select the Service Type as a WSDL Web Service. Click the Browse button and select the CurrencyConverter WSDL and the CurrencyConverterSoap port (this service can be invoked in a number of different ways but we are going to choose SOAP this time) and click Submit. Your screen should now look like:
Note: in this case we have chosen a web service but we could just as easily have chosen another type of service at this point - the basic process is the same.
Click on Last and then, on the summary screen, click Save.
Complete the session by clicking Activate in Change Center, give it a description and click Submit - you have now added a business service to Oracle Service Bus.
The last step is to test the business service in order to check the actual service is accessible from the bus. Using the Project Explorer navigate back to the Business Services folder and click on the bug icon in the Actions column, next to the business service you created, to launch the Test Console which will allow you to define the input data to send to your service. In my case I want to use my business service to find out the currency conversion rate between British pounds (GBP) and US Dollars (USD) and so I modify the sample SOAP message to set the FromCurrency to GBP and the ToCurrency to USD. If you have chosen to use the same service as me then your Test Console should look like:
To execute the test, simply click on Execute and you should see the response from your business service:
Congratulations, you have now added your first service to Oracle Service Bus!