Book Image

Oracle Service Bus 11g Development Cookbook

Book Image

Oracle Service Bus 11g Development Cookbook

Overview of this book

Oracle Service Bus 11g is a scalable SOA integration platform that delivers an efficient, standards-based infrastructure for high-volume, mission critical SOA environments. It is designed to connect, mediate, and manage interactions between heterogeneous services, legacy applications, packaged solutions and multiple Enterprise Service Bus (ESB) instances across an enterprise-wide service network. Oracle Service Bus is a core component in the Oracle SOA Suite as a backbone for SOA messaging. This practical cookbook shows you how to develop service and message-oriented (integration) solutions on the Oracle Service Bus 11g. Packed with over 80 task-based and immediately reusable recipes, this book starts by showing you how to create a basic OSB service and work efficiently and effectively with OSB. The book then dives into topics such as messaging with JMS transport, using EJB and JEJB transport, HTTP transport and Poller transports, communicating with the database, communicating with SOA Suite and Reliable Message Processing amongst others. The last two chapters discuss how to achieve message and transport-level security on the OSB.
Table of Contents (19 chapters)
Oracle Service Bus 11g Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Testing the proxy service through soapUI


In the previous recipe, we used the OSB console for testing the proxy service. This is ok to just quickly see, if the service is working. But for automatic and repeatable tests, the OSB console is not the right tool.

One advantage of using standards such as the web service standard and the SOAP-based web services is the fact that we can mix and match products from different vendors. The web service standards are vendor-neutral.

Especially for testing web services, there exists a lot of specialized products from different vendors. soapUI is such a specialized tool, which offers both a free as well as a pro version. The free version supports the testing web services with a lot of convenient functionalities. In this recipe, we will show how to test our simple proxy service through soapUI.

Getting ready

To perform this recipe, soapUI needs to be downloaded and installed. We can get it from here: http://www.soapui.org.

In order to test the service from soapUI, we need to know the WSDL URL of the deployed proxy service. The URL is constructed by the OSB at deployment time, based on the location of the OSB server (http://[OSBServer]:[Port]) and the endpoint URI specified in the proxy service (that is, /basic-osb-service/proxy/CustomerService). We need to concatenate the two and add the suffix ?wsdl to get the WSDL URL of the OSB proxy service:

http://localhost:7001/basic-osb-service/proxy/CustomerService?wsdl.

How to do it...

In soapUI, perform the following steps:

  1. In the File menu, select New soapUI Project.

  2. Enter the URL of the WSDL, for the service to be tested (http://localhost:7001/basic-osb-service/proxy/CustomerService?wsdl) into the Initial WSDL/WADL field.

  3. Enter CustomerService into the Project Name field.

  4. Click on the OK buton.

    SoapUI will analyze the WSDL and creates a project with some initial requests for all operations defined by the WSDL. Still in soapUI, perform the following steps:

  5. Expand the project in the Navigator on the left.

  6. Double-click on the Request 1 entry of the RetrieveCustomerByCriteria operation.

  7. A new window for the Request 1 will open in the details section.

  8. Replace the ? character in the request message on the left by the input parameter values for the test. The following screenshot shows the request with the ? characters replaced:

  9. Click on the green arrow to start the test.

  10. Check that a valid customer is returned in the response window on the right.

  11. Save the soapUI project so that it is available to use later.

How it works...

Thanks to the standardization through web services, a tool such as soapUI can create the right requests for a service just by analyzing the provided WSDL of the service. SoapUI creates requests for each operation of the service. These requests are persisted in the soapUI project and they can be combined into a test suite. This allows them to be automatically executed, that is, they can be used together with continuous integration.

There's more...

SoapUI is very powerful and it's worth checking the online documentation available on their website (http://www.soapui.org). In any real-live project work, we suggest you to look at the pro version as well. It simplifies a lot of the service testing even further.

Validate that the response is correct

In soapUI, perform the following steps to validate the response from the proxy service against the XML schema in the WSDL:

  1. Right-click on the response message window and select Validate.

  2. Either a pop-up window will appear indicating that the XML message is valid or the validation errors will be displayed in a window below the response message, as shown in the following screenshot:

Creating another request for the same operation

SoapUI supports more than one request per operation, so that a request can be created for each test case to be executed. It's recommended to properly name the different requests in order to be able to identify them later and to clearly indicate the case tested by a given request.

To rename a request, just right-click on the request and select Rename.

An existing request can also be cloned. This reduces the amount of work necessary to correctly set up all the information in the request message. To create a copy of a request, right-click on the request and select Clone Request.

To create a new request from scratch, right-click on the operation and select New request.

See also

To learn more about soapUI check their website: http://www.soapui.org/. There is also a pro version available, which has a lot more interesting features, a lot of them simplifying the use of soapUI for web service testing.