web 服务器 不响应 返回,Web服务响应不是从我的服务器返回

我正在开发Android应用程序和测试目的我测试本地主机它运行完美,但当我托管该服务器的Web服务时,没有响应从该网址返回。Web服务响应不是从我的服务器返回

=>我试过其他网址一样..

,并得到适当的反应如下给出。

{"ResponseCode":2,"ResponseMessage":"Invalid App Key","ResponseDateTime":"1/6/2015 4:50:28 AM GMT","Data":[]}

但从我的服务器url没有任何返回和应用程序显示继续加载数据。 这里是我的doInBackgound()方法

protected String doInBackground(String... strings) {

try {

try{

// url where the data will be posted

//String postReceiverUrl = "http://yoursmarthost.net/~html/androidtest/android_test.php";

String postReceiverUrl="https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY";

// String postReceiverUrl="https://www.whizapi.com/api/v2/util/ui/in/indian-city-by-postal-code?AppKey=your-app-key&pin=110001";

//String postReceiverUrl="http://'my url'/android_test.php";

Log.v(TAG, "postURL: " + postReceiverUrl);

// HttpClient

HttpClient httpClient = new DefaultHttpClient();

// post header

HttpPost httpPost = new HttpPost(postReceiverUrl);

// add your data

List nameValuePairs = new ArrayList(2);

nameValuePairs.add(new BasicNameValuePair("firstname", "Mike"));

nameValuePairs.add(new BasicNameValuePair("lastname", "Dalisay"));

nameValuePairs.add(new BasicNameValuePair("email", "[email protected]"));

httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// execute HTTP post request

HttpResponse response = httpClient.execute(httpPost);

HttpEntity resEntity = response.getEntity();

if (resEntity!=null) {

String responseStr = EntityUtils.toString(resEntity).trim();

Log.v(TAG, "Response: " + responseStr);

}

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

} catch (NullPointerException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

return null;

}

当我更改网址,并把我的网络服务器实际网址,当时

if (resEntity!=null) {

String responseStr = EntityUtils.toString(resEntity).trim();

Log.v(TAG, "Response: " + responseStr);

}

这里

调试指针EntityUtils.toString进入(resEntity).trim()方法但不返回并继续加载显示在Android应用程序屏幕上。

2015-01-06

kamlesh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值