File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Unit Testing Web Services. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
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

we are working on a web services project using JAX-WS and JAXB. All is fine and we are able to consume as well as publish our web services. The problem is in unit testing these web services using Junit.

Is there a standard generic approach to Unit Test Web Services, please share the names / URLs of any tools or articles on the same regard.


Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Try soapUI

===Vyas Sanzgiri===
My Blog
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
As before, soapUI is a nice tool. Take a look at the following links:
Finally, this page talks about how unit tests created in soapUI can be run from your own JUnit tests:
Best wishes!
Don Schaefer

Joined: Jan 22, 2002
Posts: 16
The approach we have generally taken for testing web services has been to write the tests on the pojos used by the webservice instead of the services themselves. The impl code merely calls the pojo with the document after applying security and transaction policy. This allows separation between the webservice implementation and our logic. This also allows for much quicker unit testing.

If you want to be a purist about it, testing through the webservice is more of an integration test. For those tests you also have to account for security, transaction policies etc. Much more that a simple junit test. For that testing we build the docs, execute the service and check the results using relative xpath expressions.

Jeff. Davis

Joined: Jun 01, 2009
Posts: 20
I agree, soapUI is a very nice open source product for testing both SOAP and RESTful web services. You can construct test cases/suites in it, and even use it to act as a server for mock-requests (they offer a commercial alternative that has a few more bells-and-whistles). In many of my examples in the book I have soapUI integrated in with ANT for testing of the example services (i.e., you run an ant target that will automatically launch soapUI along with the appropriate project).
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Thanks a lot.
I agree. Here's the link:
subject: Unit Testing Web Services.
It's not a secret anymore!