我正在试图找到一种方法来编写一个可以与json-rpc服务通信的Java应用程序(该服务是一个python twisted服务器).
然而,我还没有找到一个体面的图书馆,里面有一些很好的例子(我已经用谷歌搜索了6个小时).
那么Java中是否存在任何库,或者是否存在更加繁琐的低级方法.
您可以看一下Spring和RestTemplate类(这里是一个很好的介绍:http : //blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/)。
或者,您可以使用Commons HttpClient将Json有效负载发布/获取到服务。
PostMethod post = new PostMethod("http://myservice.com");
// add the payload to the post object
HttpClient client = new HttpClient();
int status = client.executeMethod(post);
String response = post.getResponseBodyAsString();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16404 次 |
| 最近记录: |