开发者

How to parse a list of objects retrieved with ksoap on Android?

I have a soap webservice that returns something like this:

ListResult{id=123;
result=Li开发者_Go百科stItem{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; };

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.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜