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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:34:58+00:00 2026-06-10T03:34:58+00:00

Hi I am trying to build an app where data are retrieved from a

  • 0

Hi I am trying to build an app where data are retrieved from a webs service. I am using KSOAP2 to get the data from the web service..
the data is getting passed in arraylist from the web service.. I need to save the data received in a new arraylist but I am getting ClassCastException when I try to save the object into array list..

below is the code

class NetworkConnectTask extends AsyncTask<String, Void, ViewSchedule> {

    @Override
    protected void onPreExecute() {

        super.onPreExecute();
    }

    protected ViewSchedule doInBackground(String... urls) {
        try
        {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            request.addProperty("username",username);
            request.addProperty("startdate",currentDateString);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION,envelope);
            Object result = envelope.getResponse();

            ArrayList<String> recivedlistItems = new ArrayList<String>();
            recivedlistItems=(ArrayList<String>) result; // exception caught here


            if(!recivedlistItems.isEmpty())
            {

                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        addItems("some crap");

                    }
                });
            }
            else
            {
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        addItems("No bookings");

                    }
                });
            }
        }
        catch (Exception e)
        {
            System.out.println("error");
            e.printStackTrace();
        }
        return null;
    }

    protected void onPostExecute(LoginScreen feed) {



    }

Here is code of my wsdl (web-service)

public synchronized ArrayList<String> View(String username, String startdate ) {

    System.out.println("\n entered the method");

    try {
        /* Create object of the Connect class */

        Connect connect = new Connect();
        /*
         * calling the Connection method of Connect class to establish a
         * database connection
         */
        Connection conn = connect.Connection();

        java.sql.PreparedStatement preparedStatement = null;
        /* Creating a query to be executed with prepared statement */
        String query = "select title,startdate,enddate from bookinginformation where username=? and startdate=?";

        preparedStatement = conn.prepareStatement(query);
        preparedStatement.setString(1, username);
        preparedStatement.setString(2, startdate);
        // stmt.executeUpdate(query);

        ResultSet rs = preparedStatement.executeQuery();

        boolean empty = true;
        while (rs.next()) {
            empty = false;
            String title =rs.getString(1);
            String S_date=rs.getString(2);
            String e_date=rs.getString(2);
            StringBuilder sb=new StringBuilder();
            String temp="";
            temp = sb.append(title).append("-").append(S_date).append("-")
                    .append(e_date).toString();
            listItems.add(temp);
            System.err.println("\n added  \n");
        }

        if (empty) {
            System.out.println("\n no data");
            //return "false";
        }
        rs.close();
        conn.close();

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Cannot connect to database server");
        System.exit(0);
    }
    return listItems;


}

Below is the error

java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive
at com.example.androidfrontend.ViewSchedule$NetworkConnectTask.doInBackground(ViewSchedule.java:162)
at com.example.androidfrontend.ViewSchedule$NetworkConnectTask.doInBackground(ViewSchedule.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
  • 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-10T03:35:00+00:00Added an answer on June 10, 2026 at 3:35 am

    Slight change to Swayam’s code worked for me..

    SoapObject result=(SoapObject)envelope.bodyIn;
                int childCount = result.getPropertyCount();
    
                int i;
                for (i = 0; i < childCount; i++) {
                    String temp= result.getProperty(i).toString();
                    recivedlistItems.add(temp);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I'm trying to build a web app (as a personal project using modern
I'm trying to build a Silverlight App that accesses and presents data from a
I'm trying to build a web app using Dojo. I have a form that
I'm trying to build an app that gets data from server with getJSON and
I'm trying to build an app that gets JSON from server and then shows
I'm trying to build an app using Sinatra, Ruby, rack, haml, pony and SendGrid,
I'm trying to build my app on my iPhone 4 but i keep getting
I'm trying to build and app that shows organized data so I'm thinking that
I am trying to build a desktop app to use facebook api and get
I'm trying to build an objective C app which posts data to a remote

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.