如何解析与KSOAP Android上检索对象的列表? [英] How to parse a list of objects retrieved with ksoap on Android?

查看:249
本文介绍了如何解析与KSOAP Android上检索对象的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web服务的SOAP返回是这样的:

I have a soap webservice that returns something like this:

ListResult{id=123;
result=ListItem{currencyID=2; currencyISO=EUR; desc=description; hasEMagazine=true; hasPrintMagazine=true; incentiveB=0; incentiveE=1000; objectCatalogID=123; objectID=12345; objectTypeID=1; picURL=url; priceB=222 ; priceRB=anyType{};0 sortID=0; title=title; uniqueProductAttrID=0; };
result=ListItem{currencyID=2; currencyISO=EUR; desc=description; hasEMagazine=true; hasPrintMagazine=true; incentiveB=0; incentiveE=1000; objectCatalogID=123; objectID=12345; objectTypeID=1; picURL=url; priceB=222 ; priceRB=anyType{};0 sortID=0; title=title; uniqueProductAttrID=0; };
result=ListItem{currencyID=2; currencyISO=EUR; desc=description; hasEMagazine=true; hasPrintMagazine=true; incentiveB=0; incentiveE=1000; objectCatalogID=123; objectID=12345; objectTypeID=1; picURL=url; priceB=222 ; priceRB=anyType{};0 sortID=0; title=title; uniqueProductAttrID=0; };

现在我想产生一个结果列表出这个对象。我得到的有20个属性结果对象,如果我检索这些属性之一,我得到包含整个列表项为字符串的SoapPrimitive。

Now I would like to generate a list of Results out of this object. I get a result Object that has 20 Properties and if I retrieve one of this properties I get a SoapPrimitive containing the whole ListItem as a String.

有没有检索此SoapPrimitive对象所需要的值,而无需手动解析字符串优雅的方式?

Is there an elegant way to retrieve the needed values from this SoapPrimitive Object without parsing the String manually?

推荐答案

我结束了使用反射。我通过在一个空的输出对象的遍历所有的领域,看看其中一个字段包含在肥皂的结果。看看这个教程为code的例子。

I ended up using reflection. I pass in an empty output object an iterate over all the fields to see if one of the fields is contained in the soap result. Have a look at this tutorial for code examples.

这篇关于如何解析与KSOAP Android上检索对象的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆