gpt4 book ai didi

java - 如何从 Android 上的 https url 获取 xml?

转载 作者:行者123 更新时间:2023-11-30 11:41:42 25 4
gpt4 key购买 nike

我正在查看一些包含教程的页面,以了解如何从 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>";
}

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

最佳答案

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

关于java - 如何从 Android 上的 https url 获取 xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12159606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com