Frage

I'm trying to find a way to write a java application that can communicate with a json-rpc service (The service is a python twisted server).

However I haven't been able to find a decent library with some good examples (I've googled and fiddled around for like 6 hours now).

So are there any libraries for this in Java, or is there a more-cumbersome lower level way.

War es hilfreich?

Lösung

You can take a look at Spring and the RestTemplate class (here is a good introduction: http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/).

Alternatively, you can use Commons HttpClient to post/get your Json payload to the service.

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();

Andere Tipps

Check this out: https://code.google.com/p/json-rpc-client/

The above is a JSON RPC client in Java that can talk to a JSON RPC Service.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top