2

我正在查看一些带有教程的页面,以了解如何从 url 获取 XML 并在手机上显示其中的数据,但我只找到了 http 连接。

我需要从 url 获取数据,但我无法使用 http 连接到服务器 我需要使用 https

try {

            DefaultHttpClient httpClient = new DefaultHttpClient();

            HttpPost httpPost = new HttpPost("https:...");

            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            line = EntityUtils.toString(httpEntity);

            line = con.getResponseMessage();
            //con.getResponseMessage();
        } catch (UnsupportedEncodingException e) {
            line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
        } catch (MalformedURLException e) {
            line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
        } catch (IOException e) {
            line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
        }

如何更改此片段以使用 https?有没有从 https 获取 xml 的教程?

4

1 回答 1

1

我找到了使用此页面通过 https 连接到服务器并获取 XML 的解决方案:https: //secure.mcafee.com/us/resources/white-papers/wp-defeating-ssl-cert-validation.pdf 这很有帮助。

于 2012-08-29T10:01:33.993 回答