Calling a soapui mock service from Java code?
I have started working on creating a mock service using the Soap UI framework (the eclipse plugin) and am trying to work out what the best way开发者_开发技巧 of calling the service (through creating a request) using Java is? Also, how best to parse the response?
Any information would be greatly appreciated.
If you don't have a request prepared, you can create it with groovy markup builder http://groovy.codehaus.org/Creating+XML+using+Groovy's+MarkupBuilder
The simplest way to invoke the service after you have the request is with the apache commons HttpClient.
PostMethod post = new PostMethod(url);
post.setRequestBody(requestString);
HttpClient client = new HttpClient();
int statusCode = client.executeMethod(post);
String response = post.getResponseBodyAsString();
Then you can parse the reponse with groovy xml slurper.
精彩评论