2

I was looking at some pages with tutorials to see how to get XML from url and to display a data from it on phone, but I only found http connection.

I need to get data from url but I cannot connect to server using http I need to use 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>";
        }

How can I change this fragment to use https? Is there any tutorial to get xml from https?

Unii
  • 1,587
  • 15
  • 33
  • Have You checked http://stackoverflow.com/questions/995514/https-connection-android ? Actually, xml/json it doesn't matter - receiving data is quite the same. But https and http has some major differences. – sandrstar Aug 28 '12 at 12:54
  • Refere this link http://stackoverflow.com/a/5162372/1602230 – Sathish Aug 28 '12 at 12:54
  • i don't see where is your problem here? – njzk2 Aug 28 '12 at 13:22

1 Answers1

1

I found solution to connect to server and get XML by https using this page: https://secure.mcafee.com/us/resources/white-papers/wp-defeating-ssl-cert-validation.pdf It's helps a lot.

Unii
  • 1,587
  • 15
  • 33