Restlet将JSON发布到Appengine错误

编程入门 行业动态 更新时间:2024-10-28 12:27:19
本文介绍了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编程的日子):我只是改变了设置,直到它开始工作。

我遇到的问题是:

  • 它向错误的客户端提供了错误的表示(JSON,XML,GWT)。后来事实证明,我必须关注课堂内部的方法顺序。 WTF ??
  • 我无法让它在子路径上工作,例如/休息/*。
  • 我不打算使用Restlet,原因如下(提示作者):

  • 文档是稀缺的,不准确的,有时是矛盾的(在文档的不同部分以不同方式解释文档)。
  • 配置不是标准的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:

  • 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??
  • 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):

  • Documentation is scarce, inaccurate and sometimes contradictory (explaining thing in different ways in different parts of documentation).
  • 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错误

    本文发布于:2023-10-11 04:31:18,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:错误   Restlet   JSON   Appengine

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!