开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜