开发者

Using RestEasy with Windows Live Service, how do you unmarshall the list of Contacts returned?

开发者 https://www.devze.com 2023-01-03 18:14 出处:网络
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

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 exp开发者_JAVA技巧ected 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消