Ok, well there's my answer. You have to supply a converter service. Otherwise the default is setup to return null.

Stanczak Group wrote:
Thank you for the code. Looking over everything I did find that I am getting an entity from the server. I did a response.isEntityAvailable() and it says there is something. But I noticed you use response.getEntity().write() and I'm using response.getEntityAsObject(). When I use your method I get the object, but not unserialized form. If I use response.getEntityAsObject() I get null. Why would response.getEntityAsObject() not working?

Thierry Boileau wrote:
Hello Justin,

this error is a side effect of the Simple connector, and has no impact on the running code. With the sample code attached to this mail (this is an eclipse project), I succeed in getting the returned objectRepresentation.

best regards,
Thierry Boileau
Hard to say without knowing what you are doing :)
So true, but let me re-ask that in a better way. Does using objects in Restlet make sense? As in is there another method that preforms better, is standard, or better supported that I should be using. The application is just a client/server system, and I'm writing both ends so I can use what ever works best.:)

Using ObjectRepresentation for a String is strange if that is your usecase as it is meant for a serializable Java object. If you are just wanting to pass plain text then you should use the following:

if (variant.getMediaType().equals(MediaType.TEXT_PLAIN)) {
          result = new StringRepresentation("Testing....");
      }
The method you sent works, but now I get a different error. And of course the client gets a big fat null object. I'm using Simple with Apache Http Client.


application/x-java-serialized-object
Aug 22, 2007 7:43:15 AM com.noelios.restlet.LogFilter afterHandle
INFO: 2007-08-22 07:43:15 127.0.0.1 - - 8182 GET /users/dog - 200 - - 29 http://localhost:8182 Noelios-Restlet-Engine/1.0.2 - Aug 22, 2007 7:43:15 AM com.noelios.restlet.http.HttpServerConverter commit
INFO: Exception intercepted
java.io.IOException: Stream closed
at simple.http.ResponseStream.ensureOpen(ResponseStream.java:286) at simple.http.ResponseStream.flushBuffer(ResponseStream.java:204)
       at simple.http.ResponseStream.flush(ResponseStream.java:190)
at com.noelios.restlet.http.HttpServerCall.sendResponse(HttpServerCall.java:312) at com.noelios.restlet.http.HttpServerConverter.commit(HttpServerConverter.java:90) at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:95) at com.noelios.restlet.ext.simple.SimpleProtocolHandler.handle(SimpleProtocolHandler.java:66)
       at simple.http.Dispatcher.run(Dispatcher.java:83)
       at simple.util.process.Daemon.execute(Daemon.java:121)
       at simple.util.process.Daemon.run(Daemon.java:106)
Aug 22, 2007 7:43:16 AM com.noelios.restlet.util.SecurityUtils parseResponse








--
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