java.lang.ClassCastException:org.ksoap2.serialization.SoapObject

时间:2011-12-29 00:49:11

标签: android web-services casting ksoap2

我使用库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 { ... }

感谢。

0 个答案:

没有答案