kvin024 / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Calling getProperty(string) returns anyType{} #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Calling a SOAP 1.1 Webservice that contains an element tag but no value (for 
example: <LastPaymentDate /> )
2. Calling getProperty("LastPaymentDate")

What is the expected output? What do you see instead?
I expect to see an empty string returned, as the returning XML has a 
corresponding tag but no value.

What version of the product are you using? On what operating system?
2.5.4, Win XP, Eclipse 3.5.2.

Please provide any additional information below.
Any advice appreciated on best practice to work around, or resolution.

Original issue reported on code.google.com by jvcrism...@gmail.com on 7 Apr 2011 at 7:45

GoogleCodeExporter commented 9 years ago
Try implicitTypes = false as documented on the wiki or one of the 
safeGetProperty or so methods. I think one of them has a patch on it. Check out 
the code and or javadoc for more. Somebody had this issue before and I believe 
I applied a patch or we came up with something.. 

Original comment by mosa...@gmail.com on 9 Apr 2011 at 4:52

GoogleCodeExporter commented 9 years ago
I tried the safeGetProperty method and it returns the same value. That
method seems to work on a null value, when the tag is missing in the
XML file. ImplicitTypes is set to false as you suggest.

Calling a .net soap 1.1 service btw with the dot net property set to true.

Really appreciate any help with this! Even an acceptable work around
other than testing for a string value of "anyType{}".

On Apr 9, 2011, at 12:53 AM, "ksoap2-android@googlecode.com"
<ksoap2-android@googlecode.com> wrote:

Original comment by jvcrism...@gmail.com on 9 Apr 2011 at 11:19

GoogleCodeExporter commented 9 years ago
That would work though :-)

Original comment by mosa...@gmail.com on 9 Apr 2011 at 5:30

GoogleCodeExporter commented 9 years ago
You could supply a patch that does the check in the framework ....

Original comment by mosa...@gmail.com on 9 Apr 2011 at 5:32

GoogleCodeExporter commented 9 years ago
I do that workaround nowadays. I search for anyType{} in the response. It is 
tedious but gets the work done.

Original comment by santiban...@gmail.com on 1 Sep 2011 at 7:38

GoogleCodeExporter commented 9 years ago
I suggest using the getPropertyInfo() method and check if the PropertyInfo's 
type is what you expect.

PropertyInfo pi = new PropertyInfo();
object.getPropertyInfo(0, pi);
if (pi.getType()==SoapPrimitive.class){
   LastPaymentDate = pi.getValue().toString();
} else {
   LastPaymentType = "";
}

Original comment by Konrad.B...@gmail.com on 17 Jan 2012 at 5:47

GoogleCodeExporter commented 9 years ago
Konrad.Barth... want to wrap that into a convenience method in SoapObject, 
write a test or two and submit a pull request?

Original comment by mosa...@gmail.com on 17 Jan 2012 at 6:04

GoogleCodeExporter commented 9 years ago
Created methods like getPrimitiveProperty that deliver an empty String in the 
said case and submitted a pull request.

Original comment by Konrad.B...@gmail.com on 17 Jan 2012 at 12:34

GoogleCodeExporter commented 9 years ago
Pulled https://github.com/mosabua/ksoap2-android/pull/11 into master. Will go 
out with next release.

Original comment by mosa...@gmail.com on 17 Jan 2012 at 4:43