有关Cloud Endpoints返回类型的更多信息 [英] More info on Cloud Endpoints return types

查看:68
本文介绍了有关Cloud Endpoints返回类型的更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档


返回值类型不能是简单类型,如String或int。返回值需要是一个POJO,一个数组或一个Collection。


这正是本地开发服务器上的工作原理。但是,一旦部署,原始类型的集合和数组会导致 500内部服务器错误是否键入 GET URL进入浏览器或使用API​​浏览器,尽管服务器日志显示 200 Success 。 POJO的收藏工作正常。

几个月来一直是这种情况,并通过多次尝试,采用不同的方法。这是预期的行为还是它的错误?

解决方案

我想我最近遇到了同样的事情。我试着从端点返回一个字符串集合或数组。它似乎工作 - 它生成我的客户端代码没有错误,并创建代码,专门设计来处理类型(换句话说,是的,他们的意思是它的工作)。但是,一旦部署,它就不起作用了。



最后,我从春季开始了SO Q / A(现在无法找到它)的错误,但我猜他们仍然没有修复它或更改文档。



<编辑:我找到了我正在考虑的文章。在2013-03年的这篇文章中,谷歌的Dan Holevoet最初建议使用一系列实体,但发现这并不符合所以建议将该集合包装在一个临时类中作为解决方法。那加上我上面的经验(它产生了一个StringCollection,因为我试图使用一个字符串集合),这导致我得出结论,这是一个已知问题。


According to the documentation,

the return value type cannot be simple type such as String or int. The return value needs to be a POJO, an array or a Collection.

This is exactly how things work on the local dev server. However, once deployed, collections and arrays of primitive types result in a 500 Internal Server Error whether the GET URL is typed into the browser or the APIs explorer is used, despite the fact that server logs show 200 Success. Collections of POJOs work fine.

This has been the case for months and through several attempts with different methods. Is this the intended behaviour or is it a bug?

解决方案

I think I encountered the same thing recently. I tried returning a collection or array of strings from an endpoint. It appeared to work - it generated my client code without errors and created code that appeared specifically designed to handle the type (in other words, yes, they meant for it to work). However, once deployed it didn't work.

Eventually I turned up a SO Q/A from the spring (can't find it now) in which Google became aware of the bug, but I guess they still haven't fixed it or changed the docs.

[edit: I found the post I was thinking of]. In this post from 2013-03, Dan Holevoet of Google initially suggests using a collection of entities, but finds that this doesn't work, so suggests as a work-around that the collection be wrapped in a temporary class. That, plus my experience above (it generated a StringCollection, as I was attempting to use a collection of strings), is what lead me to conclude that it is a known issue.

这篇关于有关Cloud Endpoints返回类型的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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