在Android的HTTPS请求/响应 [英] HTTPS request/response in Android

查看:172
本文介绍了在Android的HTTPS请求/响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要使用HTTPS协议,从服务供应商的响应将是一个XML文件,发送POST请求到服务提供商,需要读也。

Need to send a POST request to a Service provider using HTTPS protocol, response from the service provider will be an xml file, need to read that also.

推荐答案

您可以通过采取一看的 AndroidHttpClient 和的 HttpPost

You could start by taking a look at AndroidHttpClient and at HttpPost.

像这样的的工作:

 final AndroidHttpClient httpClient = AndroidHttpClient.newInstance(this.getClass().getSimpleName());
 HttpResponse httpresponse   = null;
 HttpEntity httpentity       = null;
 HttpUriRequest httprequest = new HttpPost("https://...");
 byte[] xmlByteArray = null;

 if ((httpresponse = httpClient.execute(httprequest)) != null) {
  if ((httpentity = httpresponse.getEntity()) != null) {
   xmlByteArray = EntityUtils.toByteArray(httpentity);
  }
 }

另外,我的<一个href=\"http://github.com/aprock/ShortcutLink/blob/master/src/org/bibimbap/shortcutlink/RestClient.java\"相对=nofollow> RESTClient实现在github上可能是有用的。
注:我使用GET检索数据,所以因人而异

Also, my RestClient on github might be useful. Note: I use GET to retrieve the data, so YMMV.

这篇关于在Android的HTTPS请求/响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆