Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Automate web service testing, Part 2: Test a web service with XMLUnit

Learn an automation technique using the IBM Rational Software Architect development platform

Mohan Jadhav (mohan.jadhav@in.ibm.com), Staff Software Engineer, IBM India Software Labs, Bangalore
Mohan Jadhav photo
Mohan K Jadhav is a staff software engineer with IBM India Software Labs, Bangalore. He is currently working on RFID offerings from IBM and has expertise in automation testing and design.
(An IBM developerWorks Contributing Author)
Mansoor Ahmed, Software Engineer, IBM Software Labs, Bangalore
Mansoor Ahmed photo
Mansoor Ahmed is a software engineer with IBM India Software Labs, Bangalore. He is currently working on WebSphere Messaging and Data Services, a telecom product, and has expertise in Web services and open source development.

Summary:  This tutorial series, developed for testers and developers who are interested in functional web service testing, walks you through automating typical web service testing using technologies, such as JUnit, Apache Commons HttpClient, and Apache XMLUnit. In this installment, Part 2, you'll learn how to create a simple web service, how to use HttpClient to invoke a web service, and how to compare the expected response and actual response using XMLUnit. The authors demonstrate these techniques on the IBM® Rational® Software Architect development platform.

View more content in this series

Date:  23 Mar 2007
Level:  Intermediate PDF:  A4 and Letter (298 KB | 18 pages)Get Adobe® Reader®

Activity:  24396 views
Comments:  

Before you start

About this series

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:

  1. Generate the client or skeleton code for the web service.
  2. Define the test inputs.
  3. Invoke the web service using the client or skeleton code.
  4. 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

About this tutorial

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.

Prerequisites

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.

System requirements

You need the following software to complete this tutorial:

1 of 7 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services, Open source
ArticleID=204111
TutorialTitle=Automate web service testing, Part 2: Test a web service with XMLUnit
publish-date=03232007
author1-email=mohan.jadhav@in.ibm.com
author1-email-cc=
author2-email=manahmed@in.ibm.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.