To test your web service, you can use Smock. Smock compares your request with the response by XML files. You just need a response.xml file with your response and a request.xml file with your request.
Maven:
<dependency> <groupId>net.javacrumbs</groupId> <artifactId>smock-easymock</artifactId> <version>0.5</version> </dependency>
Jar:
http://mvnrepository.com/artifact/net.javacrumbs/smock-easymock
Code:
private AirlineEndpoint endpoint = new AirlineEndpoint(); @Test public void testCompare() throws Exception { GetFlightsRequest request = createRequest("request.xml", GetFlightsRequest.class); GetFlightsResponse response = endpoint.getFlights(request); validate(response).andExpect(message("response.xml")); }
More info: