我正在尝试使用 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
有谁知道如何解组响应