【发布时间】:2012-03-01 12:12:24
【问题描述】:
我正在尝试连接到 REST Web 服务器,但我不知道出了什么问题。连接的代码是:
public List<Agenda> getAgenda(String dia) {
try {
Log.i(TAG, "It is inside getAgenda()");
HttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(Settings.getServiceUrl() + "/" + dia);
Log.i(TAG, Settings.getServiceUrl() + "/" + dia);
//the line above prints: http://192.168.0.100/odonto/agenda.php/2012-02-01
HttpResponse resp = client.execute(method);
//return loadFromJSONArray(client.execute(method));
Log.i(TAG, "Recebeu a response");
return loadFromJSONArray(resp);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
好吧,事情是这样的:行
Log.i(TAG, Settings.getServiceUrl() + "/" + dia);
在调试窗口上正确打印。但是行:
Log.i(TAG, "Recebeu a response");
不要打印。所以问题就出来了:
HttpResponse resp = client.execute(method);
但我真的不知道这是怎么回事!!我已经用 Firefox 测试了 REST 服务器,它工作得很好!带有过滤器以仅显示标签 System.err 的调试窗口位于链接中:
【问题讨论】:
标签: android rest httpclient