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

  • Home
  • SEARCH
  • 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 7493793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:11:02+00:00 2026-05-29T17:11:02+00:00

I am working on an android app in which i have to fetch data

  • 0

I am working on an android app in which i have to fetch data from a .Net webservice Initially methods of webservice returning simple strings.That’s fine my code is working fine and fetch strings smoothly.But my problem starts when methods return objects,I know object holds the data in XML form.I also confirmed it by debugging my code,the resultant object holds the data given below.

<?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>

<UserInfoResponse xmlns="http://tempuri.org/">

<UserInfoResult>

<UserName>Himanshu</UserName>

<Email>Himanshu@XXXXXXXX.com</Email>

</UserInfoResult>

</UserInfoResponse>

</soap:Body>

</soap:Envelope>

and my code to consume the web service is:-

public void objData(){

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2);
        Log.d("request", request.toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        Log.d("envelope", envelope.toString());

        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        Log.d("envelope", envelope.toString());

        HttpTransportSE aht = new HttpTransportSE(URL);
        aht.debug=true;
        Log.d("aht", aht.toString());

        try
        {
            aht.call(OBJ_SOAP_ACTION, envelope);
            SoapPrimitive results = (SoapPrimitive)envelope.getResponse();
            System.out.println("results="+results);
            tv4.setText(""+results);
        }
        catch (Exception e)
        {
            tv4.setText(e.getClass().toString());
            Log.d("Error",e.getClass().toString());
        }

    }

The object results holds the xml data.Now my problem is that when i print the data of that object by using the code tv4.setText(""+results); it gives me class java.lang.ClassCastException.I know that this is not the right approach to get object’s xml data,I have to parse it.But i dont know how to parse object.So please help me to parse xml contained object.Any help would be highly appreciated.Thanx 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-29T17:11:03+00:00Added an answer on May 29, 2026 at 5:11 pm

    You cannot use SoapPrimitive for complex object, you have to cast the response like below

    SoapObject response = (SoapObject) envelope.getResponse();
    

    Then if you want to cast it to an entity object(similar to the object you are sending via .net web service) you have to do like this.

    Entity class

    public class EmLogin {
    
    private String _id;
    
    private String _pwd;
    
    
    public EmLogin() {
    }
    
    public String getId() {
        return _id;
    }
    
    public void setId(String id) {
        this._id = id;
    }
    
    public String getPwd() {
        return _pwd;
    }
    
    public void setPwd(String pwd) {
        this._pwd = pwd;
    }
    
    //this is the place you are setting the SoapObject as a param
    public EmLogin(SoapObject so) throws ParseException {
    
        this._id = so.getProperty("Id").toString();// these are the properties of your xml objs
        this._pwd = so.getProperty("PasswordHash").toString();
    
    }}
    

    the way of setting the retrived soapobject to the entity class as follows.

    EmLogin = null;
    if (yourSoapObject!= null) {
        // here you are parsing the soapobject to the emlogin object as a param
        emLogin = new EmLogin(yourSoapObject);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made an android app which working fine. I implemented the Login functionality
I am developing an android app in which I have 3 spinners populated from
I am working on an Android app that displays photos which are downloaded from
I'm working on an Android app in which I have to open & close
I'm working on an Android app in which I would like to use multi-touch.
I am trying to make an Android app which will pull uploaded videos from
I am working on a Android app and I have a dilemma. I have
I have been working on an app which includes using the devices camera. After
I am working on an Android app which runs a periodic service (every 15
I am working on an android app in which I am using some Native

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.