Wednesday, 4 September 2013

Parsing ksoap2 Object in android

Parsing ksoap2 Object in android

I am getting a soap response like this.....
anyType{ViewList=anyType{View=anyType{ViewList=null; ViewID=1;
ViewName=pdfDB5L2; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB5L1;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB4; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB2L2;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB2; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB6; response=anyType{};
visibility=Assigned To; }; View=anyType{ViewList=null; ViewID=1;
ViewName=pdfDB6L2; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB7L2;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB7L3; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB7L4;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB8L1; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB8L2;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB8L3; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB8L4;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB8L5; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB9L1;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB9L2; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB9L3;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=pdfDB10L1; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB10L2;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=dbpdftest2; response=anyType{}; visibility=Assigned To;
}; View=anyType{ViewList=null; ViewID=1; ViewName=pdfDBT1;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=anyType{}; ViewName=pdfDB7L1; response=anyType{};
visibility=Assigned To; }; View=anyType{ViewList=null; ViewID=1;
ViewName=myView; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=1; ViewName=pdfDB5L3;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=anyType{}; ViewName=pdfDM13L1; response=anyType{};
visibility=Assigned To; }; View=anyType{ViewList=null; ViewID=anyType{};
ViewName=pdfDM15L1; response=anyType{}; visibility=Assigned To; };
View=anyType{ViewList=null; ViewID=anyType{}; ViewName=pdfM15;
response=anyType{}; visibility=Assigned To; }; View=anyType{ViewList=null;
ViewID=1; ViewName=MandS; response=anyType{}; visibility=Assigned To; };
}; ViewID=null; ViewName=null; response=anyType{ResponseStatus=SUCCESS; };
visibility=null; }
I am trying getting this from this request....
try { HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
if (result != null) {
System.out.println(result);
//userIsValid = parseResponse(result);
return result;
} else {
Toast.makeText(getApplicationContext(), "No Response",
Toast.LENGTH_LONG).show();
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
And parsing the soap object like this....
private boolean parseResponse(SoapObject root) {
// TODO Auto-generated method stub
for (int i = 0; i < root.getPropertyCount(); i++) {
Object property = root.getProperty(i);
if (property instanceof SoapObject) {
SoapObject category_list = (SoapObject) property;
if (category_list.hasProperty("ResponseStatus")) {
System.out.println(category_list.getProperty("dashboardName").toString());
//}
}
}
return true;
}
But here I only get the response as Success...I want to access all the
values there such as ViewName,view id etc..how can I do that..

No comments:

Post a Comment