如何在使用REST API客户端程序

时间:2015-05-12 11:25:53

标签: rest jersey-2.0

客户端客户端= Client.create();

        client.addFilter(new HTTPBasicAuthFilter("username", "password"));
        WebResource resource = client.resource("https://server.location.path");
        //WebResource.Builder builder=resource.getRequestBuilder().header("Authorization", "Basic Base64value");
        ClientResponse response = resource.accept("application/json")
                .get(ClientResponse.class);
        System.out.println(response);
        String output = response.getEntity(String.class);
        System.out.println("Output from Server .... \n");
        System.out.println(output);

我已经放置了代码,请告诉我你有什么建议吗

0 个答案:

没有答案