问题描述
我打电话在我的Android应用程序和放大器的Web服务;该方法是getGramaNiladhariData(),我得到的结果作为SoapObject。
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));
这是我得到的将String.valueOf(结果)
下面的方法我打电话返回一个复杂类型的对象,包括5属性。因为我发现在互联网上我不能让肥皂对象作为一个Web服务方法,该方法返回一个复杂类型object.If所以,我应该如何获取值的结果。
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.
我要解决的是为什么我收到anyType的{},为价值,而不是真正的价值。任何帮助将是AP preciated
What I want to solve is why i am getting anyType{}, as the value ,instead of the real value.Any help would be appreciated
推荐答案
它来不及回答。但FYI和其他人谁找到这个有用,
Its too late to answer. but FYI and others who find this useful,
做边将String.valueOf(结果)
要打印身体的全部内容。但为了使用参数的数值,首先你需要打纠正获得 SoapObject
。
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
.
我不知道是否有任何简单的方法来找到正确的 SoapObject
,但还是这样做的伎俩,一旦你得到正确的 SoapObject
然后你做。在下面找到如何找到正确的 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
,
首先,你需要检查PARAMS的数量在你的第一个 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,
那么,打印,看看哪些参数给你corect细节,
then, Print and see which param gives you the corect details,
result.getProperty(0);
result.getProperty(1);
etc ...
一旦你找到了正确的参数,然后抓住了 SoapObject
。这样,
SoapObject result2 = (SoapObject) result.getProperty(0);
然后检查此对象的数量。做上面一样,直到你得到了正确的 SoapObject
。
一旦你找到的最后一个 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());
和你将得到的输出DDMS中像下面,
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.
这篇关于重新调整一个复杂类型对象时SoapObject结果返回anyType的{}作为值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!