从android中的ksoap2获取数据
请告诉我如何检索 ksoap2 结果中的多个数据数组。 实际上让我解释一下。 我有一个员工搜索网络服务。当我按名称搜索时,它会给我多个记录。一条记录包含姓名、电话、地址等,总共 30,40 条记录。
在其他情况下,我们只收到一个输出结果,我们可以在 ksoap2 中使用以下代码,
SoapObject result=(SoapObject)envelope.getResponse(); //get response
String text = result.getProperty("response").toString();
这将从 Response 属性返回字符串,但仅针对一条记录。现在我们有多个记录,我们如何存储每个记录。或者应该如何操作所有记录。
请朋友们指导一下。 :)
让我添加更多详细信息..这是我得到的结果 xml。
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:searchResponse xmlns:ns1="urn:abcdwsdl">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[6]">
<item xsi:type="xsd:string">success</item>
<item xsi:type="xsd:string">Search results retrieved for *</item>
<item xsi:type="xsd:">
<item>
<ad_id xsi:type="xsd:string">2</ad_id>
<fname xsi:type="xsd:string">abcr</ad_text>
<lname xsi:type="xsd:string">def</location>
<phone xsi:type="xsd:float">123456</lati>
<address xsi:type="xsd:float">America</longi>
</item>
<item>
<ad_id xsi:type="xsd:string">12</ad_id>
<fnamet xsi:type="xsd:string">test user</ad_text>
<lname xsi:type="xsd:string">hello</location>
<phone xsi:type="xsd:float">987654543</lati>
<address xsi:type="xsd:float">England</longi>
</item>
</item>
<item xsi:type="xsd:int">2</item>
<item xsi:type="xsd:int">0</item>
<item xsi:type="xsd:int">0</item>
</return>
</ns1:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
please tell me how to retrieve multiple array of data in ksoap2 Result.
actually let me explain.
i have a web service of employee search. when i search by name it gives me Multiple Records. one record contain name, last name, phone, address etc and there are total 30,40 records.
in other cases where we just recieve one output result we can use the following code in ksoap2
SoapObject result=(SoapObject)envelope.getResponse(); //get response
String text = result.getProperty("response").toString();
This will return us the string from Response property but for only one record. now we have mutiple records how do we store each record. or how should be manipulate all the records.
Please friends guide me. :)
let me add some more details.. this is the xml i get as a result.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:searchResponse xmlns:ns1="urn:abcdwsdl">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[6]">
<item xsi:type="xsd:string">success</item>
<item xsi:type="xsd:string">Search results retrieved for *</item>
<item xsi:type="xsd:">
<item>
<ad_id xsi:type="xsd:string">2</ad_id>
<fname xsi:type="xsd:string">abcr</ad_text>
<lname xsi:type="xsd:string">def</location>
<phone xsi:type="xsd:float">123456</lati>
<address xsi:type="xsd:float">America</longi>
</item>
<item>
<ad_id xsi:type="xsd:string">12</ad_id>
<fnamet xsi:type="xsd:string">test user</ad_text>
<lname xsi:type="xsd:string">hello</location>
<phone xsi:type="xsd:float">987654543</lati>
<address xsi:type="xsd:float">England</longi>
</item>
</item>
<item xsi:type="xsd:int">2</item>
<item xsi:type="xsd:int">0</item>
<item xsi:type="xsd:int">0</item>
</return>
</ns1:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是解析对象数组的示例代码:
取自此处
Here's a sample code that parses an array of objects:
Taken from here
这就是答案:
ksoap2 in android in Multiple Array Data正在检索
This is The Answer:
ksoap2 in android in Multiple Array Data Retrieving
试试这个代码:
这对我有用。
Try this code:
That works for me.