Before you start
Web services are increasingly becoming key components in business applications, and with the emergence of paradigms such as Service-Oriented Architecture (SOA), the focus on web services continues to grow. In these service-oriented and service-critical applications, web service testing assumes equal significance. Rapid creation and deployment of complex web services offers a challenge to the QA team. Automating web service testing can help the team manage the effort efficiently.
Web service testing typically includes the following tasks:
- Generate the client or skeleton code for the web service.
- Define the test inputs.
- Invoke the web service using the client or skeleton code.
- Verify that the actual response is similar to that of the expected response.
Of those activities, client or skeleton code generation and response verification require the most effort.
Various tools are available to generate the client or skeleton code for a web service based on its WSDL file; however, the code generated might be proprietary and might need to be regenerated every time the WSDL changes. A solution to this problem is to eliminate the generation of the client or skeleton code and invoke the web service directly through a generic HTTP client. Later in the series, you'll see one such toolkit provided by Apache Commons HttpClient (hereafter referred to as HttpClient) API.
Similarly, response verification usually involves some kind of manual intervention, depending on the complexity of the response content. If the response contains simple elements, verification can be simple, since it requires you to just check the value in the simple element. For responses that contain complex elements and a huge list of such complex elements, manual verification can require much more effort.
This series introduces you to a technique to automate the testing of a typical web service using an array of technologies, such as JUnit, HttpClient, and Apache XMLUnit (hereafter referred to as XMLUnit). The technique is demonstrated on the development platform offered by IBM Rational Software Architect.
This series has three parts:
- Part 1 demonstrated how to create a simple web service with IBM Rational Software Architect.
- Part 2 introduces the XMLUnit, which offers the API to compare two files in XML form.
- Part 3 tests a secured web service with IBM Rational Software Architect and XMLUnit
In this second tutorial in the series, you'll create a simple web service, use HttpClient to invoke a web service, and compare the expected response and actual response using XMLUnit -- all on the IBM Rational Software Architect development platform.
To follow along with this tutorial, you should have a basic understanding of the web service and its development in Java, and have some exposure to unit testing tools, such as JUnit.
You need the following software to complete this tutorial:
- Microsoft® Windows® 98, 2000, or 2003 operating system
- IBM Rational Software Architect V6 or later (this link takes you to a trial download)
- Apache JUnit 3.8.1
- Apache Commons HttpClient 3.0.1 (download the binary archive to find commons-httpclient-3.0.1.jar)
- Apache Commons Codec 1.3 (download the binary archive to find commons-codec-1.3.jar)
- Apache XMLUnit 1.0 (download the binary archive to find xmlunit1.0.jar)



