String ExecuteGetFileCommand(String url,String [] params) {
try {
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 30000;
int timeoutSocket = timeoutConnection*2;
String ap = null;
StringBuilder builder = new StringBuilder();
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection*80);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket*80);
HttpGet getrequest = new HttpGet(url);
DefaultHttpClient getclient = new DefaultHttpClient(httpParameters);
HttpResponse respo= getclient.execute(getrequest);
if ( respo.getStatusLine().getStatusCode()!=200 )
{
return null;
}
HttpEntity ent=respo.getEntity();
// Log.i(Tools.TAG,filename);
InputStream content = ent.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
ap=builder.toString();
return ap;
}
catch (Exception ex)
{
Tools.Errorhandling(ex);
return null;
}
}
您好我创建了一个wcf服务whitch发送xml格式的文件,当我使用firefox上的restclient扩展测试服务时,通常大约140kb文件来完成但是当我用android库测试它时它只是部分。 上面的代码来自获取文件的方法。任何的想法 ?我使用了我在网上找到的每一个http库,什么也没做。