【问题标题】:HTTPS request/response in AndroidAndroid 中的 HTTPS 请求/响应
【发布时间】:2010-10-21 16:39:22
【问题描述】:

需要使用 HTTPS 协议向服务提供者发送 POST 请求,服务提供者的响应将是一个 xml 文件,也需要读取。

【问题讨论】:

    标签: android https


    【解决方案1】:

    您可以先查看AndroidHttpClientHttpPost

    这样的事情应该工作:

     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);
      }
     }
    

    另外,我在 github 上的 RestClient 可能有用。 注意:我使用 GET 来检索数据,所以 YMMV。

    【讨论】:

    • 你没有回答隐含的问题。
    猜你喜欢
    • 1970-01-01
    • 2013-03-04
    • 1970-01-01
    • 2019-09-13
    • 2011-12-01
    • 2023-03-20
    • 2018-04-27
    • 2015-07-08
    • 1970-01-01
    相关资源
    最近更新 更多