簡體   English   中英

如何從Android上的https url獲取xml?

[英]How to get xml from https url on Android?

我正在看一些帶有教程的頁面,以了解如何從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的教程?

我使用以下頁面找到了連接到服務器並通過https通過XML獲取XML的解決方案: https : //secure.mcafee.com/us/resources/white-papers/wp-defeating-ssl-cert-validation.pdf這很有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM