More info on Cloud Endpoints return types

↘锁芯ラ 提交于 2019-12-17 21:09:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20188253/more-info-on-cloud-endpoints-return-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!