java在Windows Live服务中使用RestEasy时,如何解组返回的联系人列表?
我正在尝试使用RestEasy从Windows Live获取联系人
在成功验证了我的用户之后,我打电话给https://livecontacts.services.live.com/users/@L@/rest/livecontacts 设置身份验证标头,添加我的id和我的令牌
如果我使用cUrl从命令行调用,我会得到预期的输出,但在我的web应用程序中,我得到的是胡言乱语
例如
。。。?{?[e^7E?]
当前接口类为
public interface WindowsLiveAPI {
@GET
@Path(value="/@L@{liveId}/rest/livecontacts")
Response getContacts(@PathParam("liveId") @Encoded String liveId, @HeaderParam("Authorization") String delegatedToken);
}
一次性测试:
ResteasyProviderFactory.getInstance().addMessageBodyReader(DefaultTextPlain.class);
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
WindowsLiveAPI client = ProxyFactory.create(WindowsLiveAPI.class, "https://livecontacts.services.live.com");
ClientResponse<LiveContacts> response = (ClientResponse) client.getContacts(LIVE_ID, DELEGATED_TOKEN);
System.out.println(response.getStatus()); //Produces 200 (401 after token expires)
System.out.println(response.getEntity(String.class)); //produces gibberish
有人知道如何解开回复吗
# 1 楼答案
您可以在该方法上尝试@products(MediaType.APPLICATION_XML)[如果是XML]