我正在查看一些包含教程的页面,以了解如何从网址获取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的教程?
答案 0 :(得分:1)
我找到了连接服务器并使用此页面通过https获取XML的解决方案: https://secure.mcafee.com/us/resources/white-papers/wp-defeating-ssl-cert-validation.pdf 这很有帮助。