将 RestEasy 与 Windows Live Service 结合使用,如何解组返回的联系人列表?

发布于 2024-09-06 00:15:56 字数 1235 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

祁梦 2024-09-13 00:15:56

您可以在该方法上尝试 @Produces(MediaType.APPLICATION_XML) [如果它是 XML]。

You could try @Produces(MediaType.APPLICATION_XML) [if it's XML] on the method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文