Thanks for the input Nelson.
You are right. The code in Axis does not have this bug, but I noticed that
the deserializer code
is extremely lame. Here is a snippet from
org.apache.axis.encoding.ser.SimpleDeserializer.java:
public Object makeValue(String source) throws Exception
{
// If the javaType is a boolean, except a number of different
sources
if (javaType == boolean.class ||
Boolean.class.isAssignableFrom(javaType)) {
// This is a pretty lame test, but it is what the previous code
did.
switch (source.charAt(0)) {
case '0': case 'f': case 'F':
return Boolean.FALSE;
case '1': case 't': case 'T':
return Boolean.TRUE;
default:
throw new NumberFormatException(
JavaUtils.getMessage("badBool00"));
}
}
......etc.
So it would be happy for:
deserialize("<result xsi:type=\"xsd:boolean\">foofoo</result>",
+ new Boolean(false));
Any suggestions? I would hate to make the code slower by adding
complicated casing checks.
Thanks
Rich Scheuerle
XML & Web Services Development
512-838-5115 (IBM TL 678-5115)
Nelson Minar
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
g> cc:
Subject: small patch for a more
thorough boolean test
02/05/2002 01:46
PM
Please respond to
axis-dev
There's a bug in Apache SOAP where it doesn't deserialize "1" as
"true". I wrote a test for Axis for the same bug and am including it
here. It's a patch against the latest nightly build.
I was surprised to find this bug doesn't exist in Axis. I thought
Axis, like Apache SOAP, relied on Boolean(String) to parse the XML
data - that doesn't work because Java doesn't parse "1" as true. But
the test passes, so the bug must not be there :-)
[EMAIL PROTECTED]
. . . . . . . . http://www.media.mit.edu/~nelson/
diff -Naur xml-axis/java/test/encoding/TestDeser.java
xml-axis-nelson/java/test/encoding/TestDeser.java
--- xml-axis/java/test/encoding/TestDeser.java Tue Feb 5 12:03:01
2002
+++ xml-axis-nelson/java/test/encoding/TestDeser.java Tue Feb 5
19:36:48 2002
@@ -122,7 +122,13 @@
}
public void testBoolean() throws Exception {
+ deserialize("<result xsi:type=\"xsd:boolean\">false</result>",
+ new Boolean(false));
deserialize("<result xsi:type=\"xsd:boolean\">true</result>",
+ new Boolean(true));
+ deserialize("<result xsi:type=\"xsd:boolean\">0</result>",
+ new Boolean(false));
+ deserialize("<result xsi:type=\"xsd:boolean\">1</result>",
new Boolean(true));
}