2011-06-13 80 views
0

我正在处理事件列表的应用程序,应用程序从数据库中获取事件,事件到达应用程序抛出webservice正确,但我的问题是绑定的ListView的适配器中的肥皂对象,我这样做ksoap2 webservice help

try { 
     aht.call(SOAP_ACTION, envelope); 
     resultsRequestSOAP = (SoapObject) envelope.getResponse(); 
     // rs = (SoapPrimitive) envelope.getResponse(); 

//   resultString = (List<UBAEvent>)envelope.getResponse(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    int x = resultsRequestSOAP.getPropertyCount(); 
    adapter = new MyArrayAdapter(this); 
    UBAEvent ubaEvent = new UBAEvent(); 
    for (int i = 0; i < x; i++) { 

     ubaEvent = (UBAEvent) resultsRequestSOAP.getProperty(i); 
     adapter.add(ubaEvent); 
    } 

但它是行不通的任何人可以帮助我如何将肥皂对象绑定到适配器?

+0

的http:// seesharpgears。 blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html – PedroAGSantos 2011-06-13 14:09:43

回答

0

您首先需要解析答案,您的情况是在soapobjects中是resultRequestSOAP。如果你启用调试,在变量aht你有XML响应。并且该XML已经在resultsRequestSOAP对象中解析。要retreview你做这些:

SoapObject s5 = (SoapObject)resultsRequestSOAP.getProperty(0); 
String same=s5.getProperty("name").toString(); 

后这些你建立对象ubaEvent你想复杂的类型,所以我知道最好的方法是其中之一,或者你可以尝试硬盘的方式系列化

+0

这里是一个很好的tuto链接,我从来没有尝试过,但是在我的标记列表中:D [点击此处](http:// piergiu。 wordpress.com/2010/09/13/experiencing-with-ksoap-2-and-complex-objects/) – PedroAGSantos 2011-06-13 14:08:50