자바 jsonrpc 2.0 클 라 이언 트 프로그램

4895 단어 잡담
소스 코드
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

<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.0modelVersion>

    <groupId>groupIdgroupId>
    <artifactId>JSONRPC_TESTartifactId>
    <version>1.0-SNAPSHOTversion>

    <dependencies>

        
        <dependency>
            <groupId>com.github.briandilley.jsonrpc4jgroupId>
            <artifactId>jsonrpc4jartifactId>
            <version>1.5.2version>
        dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-annotationsartifactId>
            <version>2.9.0version>
        dependency>

    dependencies>
project>

좋은 웹페이지 즐겨찾기