我編寫了一個將數據發送到ASP.NET網站的Android應用程序。當我測試應用程序,我得到的錯誤:從ASP.NET網站接收Android數據
Connection to
https://localhost:1863
refused.
我該如何解決這個問題?另外,如何將這些數據存儲到SQL Server?
HttpClient client1 = new DefaultHttpClient();
HttpPost request = new HttpPost("http://localhost:1863");
String lat = "lat",lng = "lng";
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(3);
postParameters.add(new BasicNameValuePair("lat", lat));
postParameters.add(new BasicNameValuePair("lng", lng));
try {
request.setEntity(new UrlEncodedFormEntity(postParameters));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
request.setEntity(formEntity);
// request.addHeader("Content-type", "application/x-www-form-urlencoded");
HttpResponse response;
response = client1.execute(request);
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
String page = "";
line = in.readLine();
while (line != null)
{
page = page + line;
line = in.readLine();
}
}
catch (ClientProtocolException e) {
e.printStackTrace();} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
好的,但我測試網站與我的電腦上的asp開發服務器和android在同一臺計算機上的emulater – 2012-04-18 16:50:52