我正在开发一个Android应用程序来获取wevservice的类列表
webservice的方法就像List<mytable> GetAllmytableData();
但是我无法在mytable类中强制转换数据。我创建了一个mytable类,http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html此链接建议。
还在myclass中应用 kvm序列化来投射数据。但总是得到java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
错误。
我进入soapenvelope的数据就像
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; }
我如何解析并放入我的“mytable”类的对象数组,
提供链接的任何建议
答案 0 :(得分:2)
Kishor,这是第一个多维数组:
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;
}
您可以手动获取每个属性:
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] ;
...等 如果你想检查我的答案here
答案 1 :(得分:1)
尝试使用数组而不是List。