Creating a business service to call an external SOAP-based web service
With the basic folder structure of the OSB project in place, we are ready to create our first OSB service. We will start with the business service Customer Service which will act as a wrapper of the external service. Business services in OSB are required definitions to exchange messages with enterprise information systems—such as databases and queues or other web services. The external service is a web service offered by a fictive CRM system. The business service will allow the definition of all sorts of properties for controlling how the external service is invoked:
Getting ready
Make sure that the external web service we want to invoke is started by running the script \chapter-1\getting-ready\misc\customer-external-webservice\start-service.cmd
. This service is implemented using soapUI's capabilities for creating mock services.
Verify that the service is running and available by asking it for its WSDL definition. Enter the following URI in a browser window: http://localhost:8088/mockCustomerServiceSOAP?WSDL:
How to do it...
In Eclipse OEPE, perform the following steps:
In the project tree, right-click on the business folder and select New | Business Service.
Enter
CustomerService
into the File name field, check a second time that the business folder is selected, and click on the Finish button:A new business service artifact is created in the
business
folder and the editor for the business service opens automatically.Navigate to the General tab, if it does not already have the focus, and select the WSDL Web Service radio button.
Click on the Browse button and a pop up window will show up, where the WSDL resource of the external service to be wrapped, can be selected.
Click on the Consume button.
A second pop-up window will show up where the WSDL resource can be specified:
Select URI in the Service Resource drop-down listbox.
In the URI field, enter the URL of the WSDL resource to consume. The external service provides its WSDL through the following URL: http://localhost:8088/mockCustomerServiceSOAP?WSDL.
Click on the OK button and Eclipse will consume the WSDL from this URL.
Select the CustomerServiceSOAP port on the next window.
Click on the OK button.
Select Yes on the pop-up message window to confirm that the transport configuration settings will be overwritten by the information from the selected WSDL.
Save the OSB project by selecting File | Save.
In the Project Explorer, right-click on the imported WSDL file mockCustomerServiceSOAP.wsdl and select Rename. Enter
CustomerService.wsdl
into the New name field of the pop-up window and confirm.In the Project Explorer, drag the CustomerService.wsdl file into the wsdl folder and drop it there. All the references to the WSDL file are automatically adapted by Eclipse OEPE.
Navigate to the Transport tab and check that the Endpoint URI has been replaced with the service endpoint setting from the WSDL that we consumed:
Save the artifact by selecting File | Save or by clicking on the Save toolbar button.
How it works...
The business service acts as a wrapper of our external service. Once created, we will no longer have to use the WSDL to refer to the external service, but can use the business service. This forms an additional abstraction layer, which will become handy later in some of the more advanced recipes to enable functionality in the OSB, which is applied before the real endpoint is invoked, such as SLA monitoring, service throttling, service pooling, and others. Sentence is too long, runs on too long. Would be better split into two sentences.