小编Van*_*a R的帖子

GAE云端点与android集成 - 找不到GoogleJsonResponseException 404

我编写了GAE云端点API,并已成功将它们部署到App Engine.API在本地以及在App Engine上部署后成功运行.

生成云端点后,我尝试在我的Android客户端中调用其中一个API,并抛出"未找到GoogleJSONResponseException 404"异常.在API方法中,我使用HttpURLConnection和JAXB unmarshaller来调用URL并解组XML响应.代码如下:

String uri=<some url>;
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");

JAXBContext jc = JAXBContext.newInstance(MyResponse.class);
InputStream xml = connection.getInputStream();
response = (MyResponse) jc.createUnmarshaller().unmarshal(xml);

connection.disconnect();
Run Code Online (Sandbox Code Playgroud)

为什么这只在尝试使用端点客户端库从Android客户端调用时不起作用?难道我做错了什么?

注意:我在同一个Android客户端中调用了另一个API,它只是将数据插入到数据存储区中,并且工作正常

LogCat控制台如下所示:

06-17 11:44:49.081: W/System.err(2035): com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
06-17 11:44:49.081: W/System.err(2035): Not Found
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111)
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38)
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:314)
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1060)
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:412)
06-17 11:44:49.081: W/System.err(2035):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345) …
Run Code Online (Sandbox Code Playgroud)

cloud google-app-engine android endpoint http-status-code-404

3
推荐指数
1
解决办法
2600
查看次数