我使用库ksoap2
从我的Android应用程序访问web服务。
我尝试从网络服务中获取arraylist,数据没问题,请参阅评论。
以下代码部分:
java.util.Vector<SoapObject> rs = (java.util.Vector<SoapObject>) envelope.getResponse();
if (rs != null)
{
for (SoapObject cs : rs)
{
Floor floor = new Floor();
floor.id = Integer.parseInt(cs.getProperty(0).toString()); // ok
floor.building = (Building) cs.getProperty(1); //exception
floor.name = cs.getProperty(2).toString(); // ok
Log.d("WS", "floorId = "+floor.id+" building = "+floor.building+" floorName = "+floor.name);
}
}
我不知道如何将cs.getProperty(1)
投射到Building
。它抛出异常java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
班级建设是:
public class Building implements KvmSerializable { ... }
感谢。