Search code examples
javaandroidwcfksoap2

Parsing Complex WCF response in Android


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{}; element=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?


Solution

  • 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