源码
package congpq.jsonrpc_test;
import java.net.URL;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
import static java.lang.System.*;
public class jsonrpc_test {
public static void main(String[] args) throws Throwable{
out.println("test111") ;
JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://192.168.56.100:8080"));
String res = (String) client.invoke("add", new Object[] { "bob", "the builder" }, String.class);
out.println(res);
int re = (int) client.invoke("add", new Object[] { 1 , 3 }, int.class);
out.println(re);
}
}
pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>JSONRPC_TEST</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.github.briandilley.jsonrpc4j</groupId>
<artifactId>jsonrpc4j</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
</project>