0

我正在尝试通过 POST 将数据发送到 Web 服务器。

这是我用来执行网络调用的代码:

HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpPost post = new HttpPost(url);
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding("UTF-8");
se.setContentType("application/json");
post.setEntity(se); 
HttpResponse response = client.execute(post);

json.toString()我已经使用返回有效 JSON 的jsonlint 进行了验证。

我收到此错误消息作为响应:

11-29 11:03:53.080: I/Storefront(1470): Response = <HTML><HEAD><TITLE>Service Unavailable</TITLE></HEAD><BODY><H1>Service Unavailable - Zero size object</H1>The server is temporarily unable to service your request.  Please try againlater.<P>Reference&#32;&#35;15&#46;163431d0&#46;1322593433&#46;2b040d2c</BODY></HTML>

“零大小对象”消息让我认为 JSON 数据未正确发送。

4

1 回答 1

0

因为您收到了有效的响应,所以您使用服务器的方式可能存在问题。确保您使用正确的 URL 并以预期的方式发送数据。

于 2011-11-29T20:03:28.397 回答