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

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

问题描述

根据文档

返回值类型不能是String或int等简单类型.返回值必须是 POJO、数组或集合.

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.

这正是本地开发服务器上的工作方式.然而,一旦部署,原始类型的集合和数组会导致 500 Internal Server Error服务器日志显示 200 Success 的事实.POJO 的集合运行良好.

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.

最终,我从春季(现在找不到)找到了一个 SO Q/A,其中 Google 意识到了该错误,但我想他们仍然没有修复它或更改文档.

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.

.在 2013 年 3 月的这篇博文中,Google 的 Dan Holevoet 最初建议使用实体集合,但发现这并没有t 工作,因此建议将集合包装在临时类中作为解决方法.再加上我上面的经验(当我尝试使用字符串集合时,它生成了一个 StringCollection),这使我得出结论,这是一个已知问题.

[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天全站免登陆