Testing & Monitoring Web Services Using soapUI in NetBeans IDE
Join the DZone community and get the full member experience.Join For Free
With its latest version 6.1, NetBeans IDE provides development support for JAX-WS, JAX-RPC and now Axis2 web services. Additionally, it has added support for testing and monitoring web services using soapUI.
What is soapUI?
soapUI is a leading tool for Web Services Testing, developed by eviware. It's free, open-source software, with a vast feature set that includes Functional and Load Testing for Web Services, Web Services Simulation and Web Service Monitoring. In addition to its standalone version, it provides a plugin for NetBeans, which is now available on the NetBeans IDE Update Center.
Web Service Testing and Monitoring Features in NetBeans
With the integration of soapUI Plugin in NetBeans IDE 6.1, a variety of Web Service Testing features have been added, including the following:
- Web Service Functional Testing
- Web Service Load Testing
- Web Service Simulation
- Web Service Monitoring
- Validating WS-Interoperability (WS-I) Compliance
Installation and Setup
Starting with NetBeans IDE 6.1, the soapUIModule Plugin is available from the stable update center. Once the Plugin is installed, no additional setup is needed. It adds a soapUI pop-up menu to the IDE's Tools options. Select Preferences from the pop-up menu to set up optional configuration, such as proxy settings.
Testing is an integral part of any software development process. In the case of Web Service development, it is essential to make sure the operations provided by the Web Service perform correctly. NetBeans IDE 6.1 allows users to create and execute Test Cases and Test Suites for Web Services.
Creating Test Cases
To create Web Service Tests for a Web Service, first create and deploy the Web Service you need to test. Select the Web Service Node in the Projects tab and right click on it. Invoke the "Create Web Service Tests" from the pop-up menu. The IDE downloads the WSDL for the Web Service and then displays the following dialog.
Accept all the defaults and accept the name of the Test Suite. This will create a test suite for the web service, which is shown as part of the project node.
Modifying and Executing Test Cases
The test cases or test steps are usually SOAP requests that are sent to the Web Service endpoint. They can be modified using the editor, which can be activated by a simple double-click or "Open Editor" action on the test step.
It is possible to add additional HTTP headers, authentication information or attachments to the request, using the tabs at the bottom of the editor. Test assertions can also be added. Once the test case is ready, it can be executed by pressing the green arrow (top left corner). The test case response is shown on the right side. The request log indicates the response time for this test case.
Along with functional testing, NetBeans IDE 6.1 with the soapUI Plugin provides load testing for web services.
To create a Web Service load test, right click on the Load Test Node under Web Services Tests in the project view and execute "Create Load Test" action. Specify name on the dialog and click OK. This will create the Load Test and open its Load Test Editor. The Load Test has several configurable parameters, such as number of threads, test duration, test strategy etc, which can be set using the editor. The Load Test can be executed by pressing the green arrow (top left corner). The table provides statistical information related to the execution of the service, such as the time it took to get a result from the service and the number of transactions per second.
Web Service Simulation
Web service simulation can be a very useful feature when you don't have the target Web Service available. This allows clients of the target web service to redirect to a mock version of the web service, with predefined responses. To create a mock service, right click on the port-binding node representing the target web service, under Web Services Tests node in project view. Invoke the "Generate MockService" action, which displays the following dialog.
Select the operations to be simulated, port number, and web service path information. Click OK. Specify the name of the Mock Service and click OK. This will create the Mock Service and open the Mock Service Editor. To start the Mock Service click on the green arrow (top left corner).
To modify the Mock Response, double-click on the desired Response under the MockService node in the project view. This will open the Mock Response Editor. Modify the response on the right side as required.
The soapUI Plugin adds a powerful SOAP Monitor to NetBeans IDE 6.1, allowing users to capture and perform SOAP traffic analysis between an existing client and a server. Test cases and mock services can be created easily using the captured traffic.
To launch the SOAP Monitor, right click on the Web Services Test node in the project view, and invoke the "Launch SOAP Monitor" action. This shows the following dialog:
Select the service to be monitored and appropriate port to redirect traffic, and click OK. This opens the SOAP Monitor. Now modify your web service clients to use the "Tunnel on Port" and you will see SOAP traffic on the monitor.
HTTP headers and SOAP attachments can also be monitored in the display.
Validating WS-I Compliance
The soapUI tool can validate WSDL files and/or SOAP messages against the WS-Interoperability (WS-I) specification.
To set up the soapUI plugin for NetBeans IDE to perform WS-I validation, first download the Java version of the Interoperability Testing Tool from the WS-I.org Deliverables page and unpack it. Create a WSI_HOME environment variable pointing to the downloaded and unzipped wsi-test-tools folder. Then open the IDE and navigate to Tools > soapUI > Preferences. Open the WS-I Settings tab and, in the Tool Location field, enter the location of the tool folder (identical to WSI_HOME). Select other options according to your preferences and click OK.
To validate WSDL files, right-click the binding node in the Web Service Tests node and select Check WS-I Compliance.
To validate SOAP messages, first monitor a SOAP request and response. Right-click in the response window and select Check WS-I Compliance.
Each WS-I report opens in its own tab. The report is saved automatically if you set a location to save reports in the soapUI preferences. You can also save the report manually by clicking the Save icon above the body of the report.
You can see the test configuration used to generate the test report in the Config tab. SOAP message test reports also have a Log tab, which is an XML log of the request and response SOAP exchange.
- soapUI web site (http://www.soapui.org/)
- soapUI Feature Overview (http://www.soapui.org/features.html)
- soapUI NetBeans IDE Plugin (http://www.soapui.org/netbeans/index.html)
- WS-I Testing Tools downloads (http://www.ws-i.org/deliverables/workinggroup.aspx?wg=testingtools)
Opinions expressed by DZone contributors are their own.