Restlet将JSON发布到Appengine错误 [英] Restlet POSTing JSON to Appengine error

查看:118
本文介绍了Restlet将JSON发布到Appengine错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在GAE服务器和GWT和Android客户端上安装了Restlet小应用程序。 Restlet为GWT客户端提供GWT序列化回复,向JSON客户端提供JSON。



本地和AppEngine生产服务器上的GWT序列化都可以。 b
$ b

安卓(JSON)客户端与本地开发服务器通话时,一切正常。



Android正在生产AppEngine服务器获取JSON回复,但POST失败。日志中没有错误或警告。服务器上的函数被调用,但传递的参数为空。



这是违规代码:

  @Post(json)
public void createLocationJSON(Location location){// location永远为空
//用'location'做某事
}


解决方案

为了让大家知道:我设法让GAE + Restlet + JSON + GWT经过大量的捣鼓工作。这个过程非常混乱(让我想起为Win32编程的日子):我只是改变了设置,直到它开始工作。



我遇到的问题是:


  1. 它向错误的客户端提供了错误的表示(JSON,XML,GWT)。后来事实证明,我必须关注课堂内部的方法顺序。 WTF ??

  2. 我无法让它在子路径上工作,例如/休息/*。

我不打算使用Restlet,原因如下(提示作者):


  1. 文档是稀缺的,不准确的,有时是矛盾的(在文档的不同部分以不同方式解释文档)。
  2. 配置不是标准的JAX -RS。我知道他们可以选择将其配置为JAX-RS,但文档中的所有示例都不基于此。

从那时起我切换到泽西岛


We have a small app with Restlet on the GAE server and GWT and Android clients. Restlet serves GWT-serialized replies to GWT clients and JSON to Android clients.

All is ok with GWT-serialization both locally and on AppEngine production servers.

All is ok with Android (JSON) clients talking to local dev server.

Android taking to production AppEngine server GETs JSON replies, but POST fails. There is no error or warning in logs. The function on server gets called but parameter passed is null.

This is the offending code:

@Post("json")
public void createLocationJSON(Location location) {  // location is always null
    // do something with 'location'
}

解决方案

Just to let everybody know: I managed to get GAE+Restlet+JSON+GWT working after much fiddling. The process was really chaotic (reminded me of days programing for the Win32): I was just changing settings until it started working.

The problem that I was having is:

  1. It was serving the wrong representation (JSON, XML, GWT) to the wrong clients. Later it turned out that I had to pay attention to the order of methods inside the class. WTF??
  2. I could not get it to work on sub-path, e.g. /rest/*.

I'm not going to use Restlet for the following reasons (hint to authors):

  1. Documentation is scarce, inaccurate and sometimes contradictory (explaining thing in different ways in different parts of documentation).
  2. Configuration is not standard JAX-RS. I know they have an option to configure it as JAX-RS, but all examples in docs are not based on this.

Since then I switched to Jersey.

这篇关于Restlet将JSON发布到Appengine错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆