开发者

Parsing Complex WCF response in Android

开发者 https://www.devze.com 2023-01-24 15:13 出处:网络
I need to consume a WCF webservice via SOAP under Android. I am doing this by using KSOAP2.5.2. Now as we are not allowed to edit the WCF in any way, I am currently not able to change the output which

I need to consume a WCF webservice via SOAP under Android. I am doing this by using KSOAP2.5.2. Now as we are not allowed to edit the WCF in any way, I am currently not able to change the output which the WCF service returns. That is my main problem. To solve the problem, I need to take what I get from the WCF (workaround):

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{}; eleme开发者_StackOverflow社区nt=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; }; }; }; }; }; }; }; diffgram=anyType{DocumentElement=anyType{CL_9_2_4_DestInfo=anyType{DESTINATION=.... LOTs of other data.

Now, as it seems this is some Microsoft propretary code which is in fact a full dataset/xsd(?) How can I parse this thing into a working dataset or at least make it somehow readable to my little Android?


After some further investigations I have learned that KSOAP already pared the return XML, but as it is an Microsoft .NET Dataset (which is not handled in KSOAP) it returns such a strange string. When checking HttpTransportSE.responseDump() I can get a normal XML response. However, to map/parse the response into Java objects, you have to follow this guide, which provides more than one ways: Working with XML in Androind


The link to Michaels article is about general xml parsing. If you already have KSOAP running you can just do a getResponse and that will give you nested SoapObjects that you can just parse in code setting up your Pojos or whatever from getProperty and getAttribute calls and iterating through however you need.

0

精彩评论

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