Search code examples
javaandroidweb-servicesandroid-ksoap2

getPropertyAsString(i) Error


I connected my android application with .net web service

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.serialization.PropertyInfo;


 HttpTransportSE androidHttpTransport=new HttpTransportSE(URL);
 regions=new ArrayList<String>();

 // this is the actual part that will call the webservice
 androidHttpTransport.call(SOAP_ACTION2,envelope);

 // Get the SoapResult from the envelope body.

 SoapObject result=(SoapObject)envelope.bodyIn;
 int count=((SoapObject)result.getProperty(0)).getPropertyCount();
 for(int i=0;i<count;i++){
    String str=((SoapObject)result.getProperty(0)).getPropertyAsString(i);
    regions.add(str);
 }

The above code snippet show an error in getPropertyAsString(i). I added external jars named ksoap2-android-assembly-2.4-jar-with-dependencies and ksoap2-j2me-core-2.1.2. ans imported as above. Is this error occurred because version mismatches of jar or something different reason?


Solution

  • Try this, in your case you should use it like that:

    String str=((SoapObject)result.getProperty(0)).getProperty(i).toString();