내 클라우드 엔드 포인트 방법의 모든 로컬 작업을 전개 할 때, 하나의 작업을하지만, 모든 응용 프로그램은 배포 될 때. 방법은 다음과 같습니다.500 내부 서버 오류가
@ApiMethod(name = "listUrl", path ="article/urls", httpMethod = HttpMethod.GET)
public String[] listUrl() {
List<Article> articles = getArticleList();
String[] urlArray = new String[articles.size()];
int i = 0;
for (Article article : articles)
urlArray[i++] = article.getUrl();
return urlArray;
}
3 가지 허용되는 반환 유형은 "POJO, 배열 또는 컬렉션"입니다. 하지만 아마도 String[]
이 오류를 일으킨 것으로 생각하여 대신 String
개를 반환하려고 시도했습니다.
@ApiMethod(name = "listUrl", path ="article/urls", httpMethod = HttpMethod.GET)
public CollectionResponse<String>/*String[]*/ listUrl() {
List<Article> articles = getArticleList();
List<String> urls = new ArrayList<String>();
//String[] urlArray = new String[articles.size()];
//int i = 0;
for (Article article : articles)
urls.add(article.getUrl());
//urlArray[i++] = article.getUrl();
return /*urlArray*/ CollectionResponse.<String> builder().setItems(urls).build();
}
하지만 아무 소용이 없습니다. 나는 계속해서 "500 Internal Server Error"를 얻는다. willmas을 바탕으로
2013-09-22 22:08:00.715 /_ah/spi/com.example.hiserver.ArticleEndpoint.listUrl 200 55ms 0kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0
xx.xxx.xx.xxx(my IP) - - [22/Sep/2013:22:08:00 -0700] "POST /_ah/spi/com.example.hiserver.ArticleEndpoint.listUrl HTTP/1.1" 200 129 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0" "hylyt-it.appspot.com" ms=56 cpu_ms=21 cpm_usd=0.000014 app_engine_release=1.8.4 instance=00c61b117cdf561948b997f4ec6be2ca72c139d1
메소드에 몇 가지 [추가 로깅] (https://developers.google.com/appengine/articles/logging)을 추가하고 확인할 수 있습니다. –
해당 메소드의 모든 단일 행에 로깅을 추가 했으므로 모든 것이 작동합니다 메서드 내에서 예상대로 나는 심지어 관리 콘솔 로그에서 200을 얻지 만 클라이언트 측에서는 오류 500을 표시합니다. – willlma
그 이유는 Cloud Endpoints의 경우 [반환 값 유형이 String 또는 int와 같은 단순 유형이 될 수 없다는 것입니다. 반환 값은'POJO's **의 (POJO, 배열 또는 콜렉션) (https://developers.google.com/eclipse/docs/endpoints-addentities) (암묵적으로) **이어야합니다. – willlma