Shaqimi Yusof Shaqimi Yusof - 1 year ago 116
Java Question

How to put soap response into gridview in android?

I am fairly new to android, and I have been researching here and there about how to put a response from soap webservice to gridview. I have successfully used asynctask and also used internal storage to make session-like method to prevent login repeatedly, but surprisingly when the data response shows in log, it goes something like this:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; }; diffgram=anyType{NewDataSet=anyType{Table=anyType{itemid=155; usercode=CSSCWT ; name=CSSCWT ; level=3; password=4664538057732345268530826668298694488379 ; email= ; suspend=false; systemuser=true; deptcode=JMB ; postartpage=false; ldapusercode= ; popagesize=20; porefreshmins=5; podatesequence=1; mobileno= ; pooldmessagedisplay=7; }; Table=anyType{itemid=151; usercode=CSSTKS ; name=TAN KIM SIN ; level=3; password=15526725128958598368602650 ; email= ; suspend=false; systemuser=true; deptcode= ; postartpage=false; ldapusercode= ; popagesize=20; porefreshmins=5; podatesequence=1; mobileno= ; pooldmessagedisplay=7; }; Table=anyType{itemid=156; usercode=CSSMEL ; name=CSSMEL ; level=3; password=24554526638351588705641272148333949942249 ; email= ; suspend=false; systemuser=true; deptcode= ; postartpage=false; ldapusercode= ; popagesize=20; porefreshmins=5; podatesequence=1; mobileno= ; pooldmessagedisplay=7; }; Table=anyType{itemid=158; usercode=CSSWYL ; name=CSSWYL ; level=3; password=13215756980269776576 ; email= ; suspend=false; systemuser=true; deptcode= ; postartpage=false; ldapusercode= ; popagesize=20; porefreshmins=5; podatesequence=1; mobileno= ; pooldmessagedisplay=7; }; Table=anyType{itemid=167; usercode=CSSRAY ; name=CSSRAY ; level=3; password=24554526928351758705991272155333956942257 ; email= ; suspend=false; systemuser=true; deptcode= ; postartpage=false; ldapusercode= ; popagesize=20; porefreshmins=5; podatesequence=1; mobileno= ; pooldmessagedisplay=7; }; Table=anyType{itemid=168; usercode=CINDYLIM ; name=CINDYLIM ; level=2; password=456235079768049738389084786769055893663763886739827878

i have also tried using gridview with examples before, but it was in C# and this was created using java and i couldn't find any way of putting/formatting this soap response into gridview. Even if it couldn't, i hope to be explained of a very brief example of how to, and i would try to do it. Or if anyone found a very helpful link that i overlooked, do post it here.

Also to bear in mind that the webservice created only asks for servername, database, and mssql command strings. Any help would be appreciated. Thank you!

Answer Source

Found a way to do it. Basically you just need to get the properties for each soapobjects because the json data returned is like a tree.

So what we should do is, we need to retrieve each branch from a tree;

SoapObject response = (SoapObject)responseReturned.getProperty("diffgram");

response = (SoapObject)response.getProperty("NewDataSet");

SoapObject result = (SoapObject)response.getProperty(rowIndex); //this is start of the table. Needs to be looped row per row

txtName.setText(result.getProperty(colIndex).toString().trim()); //this is where you get the value from each column.