【发布时间】:2011-12-30 22:43:14
【问题描述】:
我想从一个服务url读取一个xml,我写了代码,我的url没问题,从浏览器看,
public String getXML(){
String line = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpPost = new HttpGet("http://localhost/simplewebservice/index.php?user=1");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (Exception ex) {
Log.d("Error reading xml", ex.toString());
}
return line;
}
但它给了我以下错误java.net.SocketException: Permission denied。
谁能有更好的解决方案?
亲切的问候,
Pritom。
【问题讨论】:
-
你是否在 manifest.xml 中添加了 Internet 权限
-
不,我没有添加那个,我该怎么做???
-
我补充说,现在我的错误是
org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused