File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Unit Testing Web Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Unit Testing Web Services" Watch "Unit Testing Web Services" New topic

Unit Testing Web Services

Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Hello All,

We have a project that uses JAX-WS and JAXB for webservices.
We want to write Junit Test cases for testing web services.

The client side i.e. Junit will need stubs to be generated to test the actual web service using tool wsgen. We want to automate this process of generating stubs in a standard manner using Ant Build script.

Can anyone share a sample build script that is generating these artifacts. Please share the same.

Also share a standard practice for unit testing web services.


Aditya Kumar
Ranch Hand

Joined: Oct 31, 2006
Posts: 102
Also share a standard practice for unit testing web services.

Basically ours are text/xml based webservices -- meaning that the response we expect does not contain binary data. For unit testing this we use a simple Http Request/Response client. We feed this client with the URL of the webservice and the request XML and that is fired over an HTTP connection to the URL. The response XML is then displayed and we can compare it to what we expect it to be.

It would be insightful to know how the developers go about testing their web services...
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

There are some good resources that you can Google on this including:

Dr Dobbs article

WSUnit - A JUnit for web services

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: Unit Testing Web Services
jQuery in Action, 3rd edition