I have both matching variants. Both client and server use Java Object. But the client is requesting plain text.

Thierry Boileau wrote:
Hi,

the subject of this issue seems to be the content negociation algorithm. On one side, the client lists all media types he knows or is able to manage (the accepted media types). On the other side, the server is able to serve several representations of the same resource. The aim of the content negociation algorithm is to confront the list of all client's acceptable variants and the list of all available server's variants. When the best one has been detected (or some default one), it's time to serve it (in method Resource#getrepresentation(Variant)).

I hope this will help you,
Thierry Boileau

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new ArrayList<Preference<MediaType>>().); clientInfo.getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.APPLICATION_JAVA_OBJECT));
request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:
Here's the code:

Request request = new Request(Method.GET, "http://localhost:8182/users/dog";); ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, "admin", "admin");
       request.setChallengeResponse(authentication);
       Client client = new Client(Protocol.HTTP);
       Response response = client.handle(request);
       String str = (String) response.getEntityAsObject();
       System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an object. I have the server setup to send object.


if (variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {
           result = new ObjectRepresentation("Testing....");
           System.out.println("\nAPPLICATION_JAVA_OBJECT\n");
       }

Where am I going wrong?





--
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke

Reply via email to