Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:57:48+00:00 2026-06-02T23:57:48+00:00

In my android application I have to a read an XML file that is

  • 0

In my android application I have to a read an XML file that is stored in a server. Since this is a secured web page[SSL(https)], to access to the location(https://serverAddress/path/) where the XML file resides, normally it requires username/Password Authentication

Following is the Code that I used to read and get the XML Stream. But it always goes to the exception when it trying to execute the HttpResponse httpResponse = httpClient.execute(httpGet); statement. Exception says Not trusted server certificate.

Also have added the internet access permission <uses-permission android:name="android.permission.INTERNET" /> in the Manifest file

If the XML file is stored in a place where it doesn’t require any authentication, then it works fine. I searched everywhere but didn’t find any example that will do this. If someone can guide through this process I would be really grateful. Thanks in advance…!!!!

   try
   {
         Log.v("State","Started...");

         HttpClient httpClient = new DefaultHttpClient();
         HttpGet httpGet = new HttpGet("https://serverAddress/path/MyXMLFile.xml");
         httpGet.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials("username", "password"),HTTP.UTF_8, false));
         HttpResponse httpResponse = httpClient.execute(httpGet);
         InputStream xmlInputStream = httpResponse.getEntity().getContent();
         Toast.makeText(getApplicationContext(), this.convertStreamToString(xmlInputStream), Toast.LENGTH_LONG).show();

         Log.v("State","Finish...");
    }
    catch(Exception e)
    {
        Log.v("State",e.getMessage().toString());
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:57:49+00:00Added an answer on June 2, 2026 at 11:57 pm

    This is not http question it is https – you are using secure connection. I also had a lot of troubles with those. As a quick fix you can get your client to trust all certificates using this irreplaceable post.

    Later on consider trusting only the appropriate certificates.

    EDIT: because I know how picky SO users are. Yes it is bad practise to trust all certificates, but this can be done in 3 minutes and you can test the rest of your code. Still never forget this is potential security breach and you should switch to trusting only specified certificate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read that I can test android application on a emulator, but I
I am writing an Android application that interfaces with a RESTful service. This web
I have read about application object in android site but I couldn't understand. What
I have an Android application that connects to Facebook to request authorization of an
I have an Android application that uses the Android database to create tables and
I have a simple Android application that uses a JAR I have built. When
I have problem with my Android application. I need an application that will send
I'm currently working on a consumer mobile application project and have read that 40%
I need for my android application to save an xml file into the external
I have an xml file generated dynamically through a php code section.I need this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.