Possible Duplicate:
Parsing ksoap2 response
So I managed to call a webservice using KSoap2 in android but I can't find a way to parse the response...
So here's what I receive from the webservice
anyType{
WORCCategoriaSubcategoriaRecord=anyType{ssENCategoria=anyType{Id=1; Nome=Problema na rua; }; ssENSubcategoria=anyType{Id=1; Nome=Falta de acesso; Imagem=anyType{}; CategoriaId=1; }; };
WORCCategoriaSubcategoriaRecord=anyType{ssENCategoria=anyType{Id=1; Nome=Problema na rua; }; ssENSubcategoria=anyType{Id=2; Nome=Falta de Passadeira; Imagem=anyType{}; CategoriaId=1; }; };
}
And here's the code I'm using to call the webservice...
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
soapEnvelope.dotNet = true;
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try{
aht.call(SOAP_ACTION, soapEnvelope);
//SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
int elementCount = resultsRequestSOAP.getPropertyCount();
if(elementCount>0){
SoapObject element;
for(int i = 0;i<elementCount;i++){
element = (SoapObject)resultsRequestSOAP.getProperty(i);
}
}
}catch(Exception ex){
ex.printStackTrace();
}
Is there any way to parse it "easily" without having to so through every property "manually"? something like a XML parser...
Take a look here, I believe this code is optimized for working with complex types and returning arrays of complex types with KSOAP: