0
我的android應用程序不會POST到我的公共網站上運行的ASP NET WEB API服務。在AVD仿真器上測試時效果很好。但是,當我在我的Android手機,我得到...測試HTTP REST拒絕來自手機,但不是來自仿真器
「連接到http://www.deanblakely.com拒絕」
我的代碼後粘貼以下 謝謝,加里
private String PostToCloudService(URL url, String entityString)
{
String retstr = "";
try
{
Log.w(getClass().getName(), "copy this: " + entityString);
Log.w(getClass().getName(), "URL is: " + url);
HttpResponse response = null;
HttpParams myParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(myParams,5000);
HttpConnectionParams.setSoTimeout(myParams, 5000);
HttpClient httpclient = new DefaultHttpClient(myParams);
HttpPost myPost = new HttpPost(url.toString());
StringEntity se = new StringEntity(entityString);
myPost.setEntity(se);
myPost.setHeader("Accept", "application/json");
myPost.setHeader("Content-type", "application/json");
response = httpclient.execute(myPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null)
{
Log.w(getClass().getName(), "response from getentity is " + line);
retstr = line;
}
}
catch (Exception e)
{
Log.w(getClass().getName(), e.getMessage().toString());
retstr = "error " + e.getMessage().toString();
}
return retstr;
}
任何在logcat? – Squonk