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.bodyIn; Log.d("WS", String.valueOf(result));
And this is what I got for String.valueOf(result)
Here the method i am calling returns a complexType object,consist of 5 attributes. As i found in the internet i can't get a soap Object as the result of a webservice method which return a complexType object.If so,how should i get the values.
What I want to solve is why i am getting anyType{}, as the value ,instead of the real value. Any help would be appreciated
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With