package sample.hello.resources;
import javax.ws.rs.core.MediaType;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
public class Test {
public static void main(String[] args) {
Client c = Client.create();
WebResource r = c
.resource("http://122.204.161.79:8899/ws/basic/department/list");
String XMLRes = r.header("reignid", "1")
.accept(MediaType.APPLICATION_JSON).get(String.class);
System.out.println("-------XMLRes-result----"+XMLRes);
}
}
报错:
Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: GET http://122.204.161.79:8899/ws/basic/department/list returned a response status of 406 Not Acceptable
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:507)
at sample.hello.resources.Test.main(Test.java:29)