views:

66

answers:

2

Hello everybody. I use a ksoap2 lib for communicating from android client with SOAP web service. Great job was done by ksoap team, but the problem is, there is no any good example how to use it correct in different aspects. For instance I get in soap response following data:

anyType{
    StatusSetting=anyType{Id=1; Name=Til afskrivning; LocationId=1; Editable=true; Default=true; Transcribed=false; }; 
    StatusSetting=anyType{Id=2; Name=Afskrevet; LocationId=1; Editable=false; Default=false; Transcribed=true; }; 
    ...
}

It's a complex object, or rather a collection of StatusSetting objects. When I try to get a property of SoapObject it's only 1 property with all that data as a string. It can't be parsed as json too. Unbelievable that nobody met same problem regarding to popularity android is gaining. Would be very cool to know if somebody solved this issue and how. Thanks.

A: 

Here is a tutorial on how to work with array of complex objects with KSOAP. I found out by countless hours of debugging. Hope this hepls

DFDF
A: 

SoapObject countryDetails = (SoapObject)envelope.getResponse(); System.out.println(countryDetails.toString());

                 ArrayList list = new ArrayList(countryDetails.getPropertyCount());
                  lv_arr = new String[countryDetails.getPropertyCount()];
                  for (int i = 0; i < countryDetails.getPropertyCount(); i++) {
                      Object property = countryDetails.getProperty(i);
                      if (property instanceof SoapObject) {
                          SoapObject countryObj = (SoapObject) property;
                          String countryName = countryObj.getProperty("countryName").toString();
                          list.add(countryName );

                      }
                  }

Hope it should work

mac