Android 上的 Ksoap——从 Java Web 服务获取列表响应
我有一个 java web 服务(soap),我想将它与 android 客户端一起使用,因为我正在使用 ksoap。
我的网络服务给出的答案如下所示:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listealbumResponse xmlns:ns2="http://ws/">
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2008</annee>
<id>6</id>
<titre>Ninja Tuna</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2008</annee>
<id>10</id>
<titre>Fine Music, Vol. 1</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2004</annee>
<id>14</id>
<titre>Bob Acri</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2009</annee>
<id>54</id>
<titre>Rated R</titre>
</return>
</ns2:listealbumResponse>
</S:Body>
</S:Envelope>
这是一个对象列表
要调用我的网络服务,我使用此代码:
try{
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(Request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
当我测试我的响应“结果”时,它是只有一个对象,我如何获取所有列表并解析它?
I have a java web service (soap) which i want to use with an android client for that am using ksoap.
My web service gives an answer which look like this :
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:listealbumResponse xmlns:ns2="http://ws/">
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2008</annee>
<id>6</id>
<titre>Ninja Tuna</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2008</annee>
<id>10</id>
<titre>Fine Music, Vol. 1</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2004</annee>
<id>14</id>
<titre>Bob Acri</titre>
</return>
<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:album">
<annee>2009</annee>
<id>54</id>
<titre>Rated R</titre>
</return>
</ns2:listealbumResponse>
</S:Body>
</S:Envelope>
wich is a list of object
To call my web service i use this code :
try{
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(Request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
When i tested my response "result" it's got only one object , how could i get all the list and parse it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是,当我解析肥皂响应时,我只得到了列表的第一个对象,所以我改变了这一行:
用:
我得到了所有列表,我添加了这个
祝你好运,谢谢Janusz
The problem was that when i parse the soap response i got only the first object of the list so i changer this line :
with :
wiht that i got all the list and i add this
Good luck and thank you Janusz
代码:
Code:
结果是一个 SoapObject 这个对象应该有您请求的列表中每个项目的属性。您可以执行以下操作来检索所有项目:
The result is a single SoapObject this objects however should have a property for every item in the list that you requested. You could do something like this to retrieve all the items: