Search code examples
javaandroidksoap2android-ksoap2

Android Ksoap get a list array of class from webservice


i am developing an android application to get a list of class from wevservice

the method of webservice is like List<mytable> GetAllmytableData(); But i cant cast that data in my mytable class. i create a mytable class as http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html this link suggested. also applied kvm serialization in myclass to cast data. but always getting getting java.lang.ClassCastException: org.ksoap2.serialization.SoapObject error.

Data i getting in soapenvelope is like

anyType{DisplayName=a; Email=hi@y.com; FirstName=a; LastChangedDate=2/5/2012 11:24:38 PM; LastName=a; ObserverID=1; UserID=1; }
anyType{DisplayName=b; Email=hi@y.com; FirstName=b; LastChangedDate=2/5/2012 11:25:52 PM; LastName=b; ObserverID=1; UserID=2; }
 anyType{DisplayName=c; Email=hi@y.com; FirstName=c; LastChangedDate=2/6/2012 9:10:44 AM; LastName=c; ObserverID=3; UserID=3; }

how i can parse and put in my "mytable" class's object array,

any suggestion on link plz provided


Solution

  • Kishor, this is a multi dimensional array take the first one:

    anyType//property 0 
    {
     DisplayName=a; // property 0 [0]
     Email=hi@y.com; // property 0 [1]
     FirstName=a; // property 0 [2]
     LastChangedDate=2/5/2012 11:24:38 PM; //etc...
     LastName=a; 
     ObserverID=1;
     UserID=1; 
    }
    

    you can get each property manually like that:

    SoapObject yourResponseObject = (SoapObject) soapEnvelope.bodyIn;
    SoapObject array = (SoapObject) yourResponseObject .getProperty(0);// this is -->anyType //property 0           
    
    SoapObject DisplayName= (SoapObject)array .getProperty(0);// this is--> //   property 0 [0]  ;
    SoapObject Email= (SoapObject)array .getProperty(1);// this is--> //   property 0 [1]  ;
    

    etc... also if you want check my answer here