Client client = Client.create();
WebResource webResource = client.resource(uri);
Builder builder = webResource.accept(MediaType.APPLICATION_JSON);
ClientResponse response = null;
if (Method.GET.equals(method)) {
response = builder.get(ClientResponse.class);
} else if (Method.POST.equals(method)) {
response = builder.post(ClientResponse.class);
}
// System.out.println("DEBUG data=" + data);
// System.out.println("DEBUG response=" + response.toString());
// System.out.println("DEBUG response headers=" + response.getHeaders().toString());