开发者

RESTlet 2.0 tutorial application does not work on appengine

开发者 https://www.devze.com 2023-01-14 13:47 出处:网络
I have been playing with the source code available from the following tutorial. The GWT/GAE application works in development mode, however when its deployed, the server always returns the response in

I have been playing with the source code available from the following tutorial.

The GWT/GAE application works in development mode, however when its deployed, the server always returns the response in the JSON format.

I am using the Restlet 2.0 开发者_运维问答Testing jars, and have also included the dependent libraries.

thank you


I had similar problem you are now experiencing:

Restlet POSTing JSON to Appengine error

As described in my own answer I managed to get it working after much fiddling.

Since then I switched to Jersey.


Two things to consider:

Editions

You need to use the GAE edition of Restlet for the server-side app, and the GWT for the client-side app. Neither will suffice for both. For this reason, the two apps are separate projects in the tutorial archive. So make sure you're using the appropriate edition for each side.

Object/Representation Conversion/Serialization and Extensions

I believe that with Restlet 2.0, when a class method annotated with an HTTP method returns a Java object, and doesn't specify how it should be serialized -- converted to a representation -- then Restlet will defer to whichever Restlet extensions are in the classpath which implement this.

In the tutorial, the server-side app includes this jar: "org.restlet.ext.jackson: Jackson extension used to generate JSON representations of the contact resource" -- which I believe is the reason that the response is JSON; the framework is deferring to the extension, which is converting the object into a JSON representation.

Therefore, if, for example, you wanted the framework to automatically serialize your objects into XML, you could remove the Jackson extension JAR from the classpath, and instead include the XStream extension. I believe that would cause the framework to serialize the objects as XML.

The wiki page for ConverterService lists the various conversions which the framework supports, and which modules enable them.

HTH!

0

精彩评论

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