如何在soap中将soap响应放入gridview?

时间:2015-10-14 15:11:08

标签: java android gridview soap ksoap2

我对android很新,我一直在研究如何将soap webservice的响应发送到gridview。我已成功使用asynctask并使用内部存储来制作类似会话的方法以防止重复登录,但令人惊讶的是,当数据响应显示在日志中时,它会是这样的:

anyType的{架构= {anyType的元素= anyType的{的complexType = {anyType的选择= {anyType的元素= anyType的{的complexType = {anyType的序列= {anyType的元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{};元素= anyType的{}; }; }; }; }; }; }; };的DiffGram = anyType的{NewDataSet = anyType的{表= anyType的{的itemid = 155; usercode = CSSCWT; name = CSSCWT;电平= 3;密码= 4664538057732345268530826668298694488379; email =;暂停= FALSE; systemuser = TRUE; deptcode = JMB; postartpage = FALSE; ldapusercode =; popagesize = 20; porefreshmins = 5; podatesequence = 1; mobileno =; pooldmessagedisplay = 7; };表= anyType的{的itemid = 151; usercode = CSSTKS; name = TAN KIM SIN;电平= 3;密码= 15526725128958598368602650; email =;暂停= FALSE; systemuser = TRUE; deptcode =; postartpage = FALSE; ldapusercode =; popagesize = 20; porefreshmins = 5; podatesequence = 1; mobileno =; pooldmessagedisplay = 7; };表= anyType的{的itemid = 156; usercode = CSSMEL; name = CSSMEL;电平= 3;密码= 24554526638351588705641272148333949942249; email =;暂停= FALSE; systemuser = TRUE; deptcode =; postartpage = FALSE; ldapusercode =; popagesize = 20; porefreshmins = 5; podatesequence = 1; mobileno =; pooldmessagedisplay = 7; };表= anyType的{的itemid = 158; usercode = CSSWYL; name = CSSWYL;电平= 3;密码= 13215756980269776576; email =;暂停= FALSE; systemuser = TRUE; deptcode =; postartpage = FALSE; ldapusercode =; popagesize = 20; porefreshmins = 5; podatesequence = 1; mobileno =; pooldmessagedisplay = 7; };表= anyType的{的itemid = 167; usercode = CSSRAY; name = CSSRAY;电平= 3;密码= 24554526928351758705991272155333956942257; email =;暂停= FALSE; systemuser = TRUE; deptcode =; postartpage = FALSE; ldapusercode =; popagesize = 20; porefreshmins = 5; podatesequence = 1; mobileno =; pooldmessagedisplay = 7; };表= anyType的{的itemid = 168; usercode = CINDYLIM; name = CINDYLIM;级= 2;密码= 456235079768049738389084786769055893663763886739827878

我之前尝试过使用gridview和例子,但它是在C#中使用java创建的,我无法找到将这个soap响应放入/格式化为gridview的任何方法。即使它不可能,我希望能够解释一个非常简短的例子,我将尝试这样做。或者,如果有人发现我忽略了一个非常有用的链接,请在此处发布。

还要记住,创建的webservice只询问servername,database和mssql命令字符串。任何帮助,将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

找到了一种方法。基本上你只需要获取每个soapobjects的属性,因为返回的json数据就像一棵树。

所以我们应该做的是,我们需要从树中检索每个分支;

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.