我这样做:
WebResource resource = client.resource(urlStr);
resource.accept(MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE);
GenericType<List<EMailInformations>> genericType = new GenericType<List<EMailInformations>>() {};
List<EMailInformations> response = null;
try{
response = resource.get(genericType);
} catch (UniformInterfaceException ue) {
ClientResponse clientResponse = ue.getResponse();
}
Run Code Online (Sandbox Code Playgroud)
类EMailInformations
@XmlRootElement
public class EMailInformations {
private long id;
public EMailInformations(){
}
public EMailInformations(long id) {
super();
this.id = id;
}
//getters & setters ...
}
Run Code Online (Sandbox Code Playgroud)
一些JSON响应
{"cn":[{"id":"302","l":"7","d":1308239209000,"rev":14667,"fileAsStr":"TAICHIMARO, Marouane","_attrs":{"lastName":"TAICHIMARO","imAddress1":"other:......
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
21 juin 2011 16:56:01 com.sun.jersey.api.client.ClientResponse getEntity
GRAVE: A message body reader for Java class java.util.List, and Java type java.util.List<fr.liberacces.pool.liferay.connecteur.modele.EMailInformations>, …Run Code Online (Sandbox Code Playgroud)