SoapObject Result returns anyType{} as value when retuning a complexType object

后端 未结 4 2097
太阳男子
太阳男子 2021-02-06 10:58

I am calling a web service in my android app & the method is getGramaNiladhariData(), I am getting the result as a SoapObject.

result = (SoapObject) envelope.         


        
4条回答
  •  迷失自我
    2021-02-06 11:34

    Its too late to answer. but FYI and others who find this useful,

    By Doing String.valueOf(result) you are printing the whole content of the body. but in order to get your values using parameters, first of all you need to hit in to correct SoapObject.

    I don't know if there is any easy way to find correct SoapObject, but still this way do the trick, and once you get the correct SoapObject then you are done. find below how to find the correct SoapObject,

    First you need to check the count of params in your very first SoapObject,

    result.getPropertyCount();
    

    you will get less amount of count for this since this is the very first cover,

    then, Print and see which param gives you the corect details,

    result.getProperty(0);
    result.getProperty(1);
    etc ...
    

    Once you found the correct parameter, then grab that SoapObject. like this,

    SoapObject result2 = (SoapObject) result.getProperty(0);
    

    then check for the count of this object. and do the same as above until you get the correct SoapObject.

    Once you found the last SoapObject it will print like this without useless strings,

    anyType{gnName = Prasad; address = Address of the person; ; workingDays = 5; gnDivision = California; contactNumber = 0123456789}
    

    Now you can go ahead with this object like this,

    SoapObject result3 = (SoapObject) result2.getProperty(5);
    Log.v("Name : ", result3.getProperty("gnName").toString());
    

    And you will get the output in DDMS like below,

    Name : Prasad
    

    I guess this will help you, let me know if you have any further issues.

提交回复
热议问题