Stanczak Group <justin <at> stanczakgroup.com> writes:

> 
> The code shows I need to supply a ConverterService for this to work, 
> how? I don't see how to add it to this:
> 
> Request request = new Request(Method.GET, 
> "http://localhost:8182/users/dog";, new ObjectRepresentation(""));
>             ChallengeResponse authentication = new 
> ChallengeResponse(ChallengeScheme.HTTP_BASIC, "admin", "admin");
>             request.setChallengeResponse(authentication);
>             request.getClientInfo().getAcceptedMediaTypes().add(new 
> Preference<MediaType>(MediaType.APPLICATION_JAVA_OBJECT));
>             Client client = new Client(Protocol.HTTP);
>             Response response = client.handle(request);
>             String str = (String) response.getEntityAsObject();
>             System.out.println(str);
> 
> It shows the code using Application to get the service, but I don't see 
> how I'm supposed to add the service. If I add an Application to the 
> attributes it wants me to create a Restlet. Where am I going wrong here?
> 

Justin,

If you are trying to get a serialized object from the request, you will need to
use ObjectRepresentation and do something like this:

Response response = client.handle(request);
ObjectRepresentation or = new ObjectRepresentation(response.getEntity());
Dog dog = (Dog)or.getObject();

Hope this helps.




Reply via email to