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 7160079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:20:19+00:00 2026-05-28T13:20:19+00:00

My android application sends a web service request and gets the response from web

  • 0

My android application sends a web service request and gets the response from web service in xml, with the embedded data in JSON. I am saving this in a string. Now I do not know how to get the JSON data from this string.

    System.setProperty("http.keepAlive", "false");
            // request parameters
            HttpParams params = httpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, 10000);
            HttpConnectionParams.setSoTimeout(params, 15000);
            // set parameter
            HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true);

            // POST the envelope
            HttpPost httppost = new HttpPost(url);
            // add headers
            httppost.setHeader("SOAPAction", soapAction);
            httppost.setHeader("Content-Type", "text/xml; charset=utf-8");
    //      httppost.setHeader("Content-Length",
    //              String.valueOf(requestEnvelope.length()));
            httppost.setHeader("SOAPAction", "http://tempuri.org/"
                    + methodName);



    //      String responseString = "";
            try {

                // the entity holds the request
                HttpEntity entity = new StringEntity(requestEnvelope);
                httppost.setEntity(entity);
HttpResponse response = httpClient.execute(httppost);
            String result = EntityUtils.toString(response.getEntity());

This is the response from the server, which I get in the result string.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ValidatePassCodeResponse xmlns="http://tempuri.org/">
<ValidatePassCodeResult>
[{"ID":1929,"Headline":"Test News","Detail":"","SubmitDate":"1/17/2012 12:08:04 PM"}]
</ValidatePassCodeResult>
</ValidatePassCodeResponse>
</soap:Body>
</soap:Envelope>

Thanks in advance.

  • 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-05-28T13:20:20+00:00Added an answer on May 28, 2026 at 1:20 pm

    This is how I removed the tags of xml string and obtained the json string from that, then I parsed the string to json array and obtained the result.

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                XmlPullParser xpp = factory.newPullParser();
    
                xpp.setInput(new StringReader(result));
                int eventType = xpp.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    if (eventType == XmlPullParser.START_DOCUMENT) {
                        System.out.println("Start document");
                    } else if (eventType == XmlPullParser.START_TAG) {
                        System.out.println("Start tag " + xpp.getName());
                    } else if (eventType == XmlPullParser.END_TAG) {
                        System.out.println("End tag " + xpp.getName());
                    } else if (eventType == XmlPullParser.TEXT) {
                        responseString = xpp.getText();
                        System.out.println("Text " + xpp.getText());
                    }
                    eventType = xpp.next();
                }
                System.out.println("End document");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application which sends json data to PHP script. The PHP
I am due to make an android application which sends and recieves data from
I am writing an Android application that interfaces with a RESTful service. This web
I am currently trying to send some data from and Android application to a
I've been assigned to create an RESTful Android application for an existing web service
My android application sends data to my website. Right now, anyone who can trace
I have an Android application from which I want to upload some data to
I want to develop application that sends image/txt or any file from one android
We have an android application that we're trying to use for web-service communication. We
I have a self-hosted WCF web service running, and an Android client application. I

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.