This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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.
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).