0
貝婁是我用於調用服務代碼,但它給了超時異常的Android超時異常
**DefaultHttpClient httpC = new DefaultHttpClient();
HttpProtocolParams.setUseExpectContinue(httpC.getParams(), false);
HttpConnectionParams.setConnectionTimeout(httpC.getParams(), 15000);
HttpConnectionParams.setSoTimeout(httpC.getParams(), 15000);
HttpPost httpPost = new HttpPost(WebServiceDetails.URL_WS_USER);
httpPost.setHeader("SOAPAction", soapAction);
try {
se = new StringEntity(serviceXml,HTTP.UTF_8);
se.setContentType("text/xml");
httpPost.setEntity(se);
BasicHttpResponse basicHttpResponse = (BasicHttpResponse)httpC.execute(httpPost);
HttpEntity responseEntity = basicHttpResponse.getEntity();
InputStream inputStream = null;
inputStream = responseEntity.getContent();
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream),1024*5);
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
System.out.println("Response from service -"+total.toString());
xmlContent=total.toString();
System.out.println(" status Line = "+basicHttpResponse.getStatusLine());
}catch (Exception e){e.printStackTrace();}**
它是工作在模擬器,但不是實際的設備上,請提出任何教程或例子,如果它是錯了.......
thanksx ...
請看看我那樣做只是 HttpConnectionParams.setConnectionTimeout(httpC.getParams(),75000); HttpConnectionParams.setSoTimeout(httpC.getParams(),75000); 但仍然存在問題.... –
你可以發佈你的logcat嗎? – waqaslam