将 RestEasy 与 Windows Live Service 结合使用,如何解组返回的联系人列表?
我正在尝试使用 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);
}
ThrowAway 测试:
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
有谁知道如何解组响应
I'm trying to get my contacts from Windows Live using RestEasy
After succesfully authenticating my user, I've made the call to https://livecontacts.services.live.com/users/@L@/rest/livecontacts
Set the authentication header, added my id and my tokens
If i make the call from command line using cUrl I get the expected output, but in my web application I'm getting back gibberish
e.g.
...?{?[??e^7E?...
Current interface class is
public interface WindowsLiveAPI {
@GET
@Path(value="/@L@{liveId}/rest/livecontacts")
Response getContacts(@PathParam("liveId") @Encoded String liveId, @HeaderParam("Authorization") String delegatedToken);
}
ThrowAway test:
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
Does anyone have any clue how to unmarshal the response
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在该方法上尝试 @Produces(MediaType.APPLICATION_XML) [如果它是 XML]。
You could try @Produces(MediaType.APPLICATION_XML) [if it's XML] on the method.