1
public static UserFriendListContainer getFriendList(SoapObject wizardobject)//TESTED
    {
        UserFriendListContainer container= new UserFriendListContainer();


        List<UserFriendListModel> list= new ArrayList();    

        String currobj= wizardobject.getProperty("FriendListResult").toString();

        Log.v("CurrentObjet+++++++",currobj.toString());




        container.setParserResult(currobj);



        SoapObject result = (SoapObject)wizardobject;
        for(int i=0;i<result.getPropertyCount();i++)
        {

                SoapObject object = (SoapObject)wizardobject.getProperty(i);//here it is break

Log.v("result:::::",result.toString());
                Log.v("obj:::::",object.toString());
                Log.v("friendID",object.getProperty("friendid").toString());
                String friendID=object.getProperty("friendid").toString();

                Log.v("friendname",object.getProperty("friendname").toString());
                String friendname=object.getProperty("friendname").toString();

                Log.v("lastaction",object.getProperty("lastaction").toString());
                String lastaction=object.getProperty("lastaction").toString();

                Log.v("friendphoto",object.getProperty("friendphoto").toString());
                String friendphoto=object.getProperty("friendphoto").toString();

                UserFriendListModel model=new UserFriendListModel();
                model.setfriendID(friendID);
                model.setfriendName(friendname);
                model.setfriendPhoto(friendphoto);
                model.setLastAction(lastaction);

                list.add(model);
            }
            container.setList(list);

        return container;
    }

}

-----
<message name="FriendListRequest"/>
<message name="FriendListResponse">
<part name="FriendListResult" type="tns:FirendListArray"/>
</message> 

我来自webservice的xml部分就是那个。我试图通过解析来访问我的好友列表。我无法理解..当我调试它时它打破了“SoapObject object =(SoapObject)wizardobject.getProperty(i)”..我想知道如何我可以解析一个我从 web 服务中获取的列表吗?谢谢您提前提供的帮助...

4

2 回答 2

1
public static UserFriendListContainer getfriendlist(SoapObject wizardobject) throws XmlPullParserException, IOException {

        UserFriendListContainer container= new UserFriendListContainer();
        UserFriendListModel model = new UserFriendListModel();

         List<UserFriendListModel> list= null;
          list=new ArrayList<UserFriendListModel>();
        Vector vector = (Vector) wizardobject.getProperty("FriendListResult");

          Log.v("vector+++++++",vector.toString());
          System.out.println("vectorsize+++++++"+vector.size());

          int count=vector.size();


          for (int i = 0; i <count; ++i) { 

        SoapObject test=(SoapObject)vector.get(i);


          Log.v("test+++++++",test.toString());  

               Log.v("friendid",test.getProperty("friendid").toString());
                String friendID=test.getProperty("friendid").toString();

                Log.v("friendname",test.getProperty("friendname").toString());
                String friendname=test.getProperty("friendname").toString();

                Log.v("lastaction",test.getProperty("lastaction").toString());
                String lastaction=test.getProperty("lastaction").toString();

                Log.v("friendphoto",test.getProperty("friendphoto").toString());
                String friendphoto=test.getProperty("friendphoto").toString();

                model.setfriendID(friendID);
                model.setfriendName(friendname);
                model.setfriendPhoto(friendphoto);
                model.setLastAction(lastaction);

                list.add(model);
            }
            container.setList(list);
            System.out.println("List==="+list);


         return container;
    }

大家好, 经过这么多努力,我找到了答案..我可以用上面的代码解析我的数组..谢谢你的兴趣..

于 2012-06-18T13:12:33.307 回答
0

你确定wizardobject.getProperty(i)

返回一个 SoapObject?? 我会尝试使用字符串,或者只是在不进行强制转换的情况下对其进行调试,看看它是什么类型的对象。

检查这个-> SoapObject 文档

顺便说一句,如果您发布错误堆栈跟踪会更方便。

于 2012-05-30T08:44:32.517 回答