According the docs at
https://jaxb.java.net/nonav/2.2.4/docs/api/javax/xml/bind/DatatypeConverter.html#parseBoolean(java.lang.String)
"parseBoolean
public static boolean parseBoolean(String
<http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true> lexicalXSDBoolean)
IllegalArgumentException
<http://download.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true> -
if string parameter does not conform to lexical value space defined in
XML Schema Part 2: Datatypes for xsd:boolean."
According to
http://www.w3.org/TR/xmlschema-2/#boolean
"An instance of a datatype that is defined as ·boolean· can have the
following legal literals {true, false, 1, 0}."
From this, it appears that the examples cited should cause a
IllegalArgumentException.
Ron
On 06/10/2014 1:32 PM, Gary Gregory wrote:
what about doIt("truthiness")?
:-)
Gary
On Mon, Oct 6, 2014 at 10:49 AM, Daniel Kulp <[email protected]> wrote:
This is also not really a bug in CXF but a bug in the JDK. The JAXB
runtime would use javax.xml.bind.DatatypeConverter to parse the booleans
and if I write a quick test like:
@Test
public void foo() {
doIt("true");
doIt("1");
doIt("trud");
doIt("trus”);
doIt("trued");
}
public static void doIt(String s) {
Boolean b = javax.xml.bind.DatatypeConverter.parseBoolean(s);
System.out.println(s + ": " + b);
}
I get:
true: true
1: true
trud: true
trus: true
trued: true
Thus, this is really outside of CXF’s control as Oracle would need to fix
this in the JAXB runtime.
That said, you can turn on schema validation and that SHOULD catch this.
I believe the schema validator is much much more strict about this.
Dan
On Oct 6, 2014, at 7:49 AM, santodip <[email protected]> wrote:
I have written a web service using CXF. The WSDL contains one of the
field as
'boolean'. Unfortunately at runtime I found that when "trud", "trua" or
"truee" is passed through that field, it accepts the value as "true".
This
should have been a "false" value for a boolean field.
Any suggestion is highly appreciated
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-accepts-tru-for-boolean-fields-tp5749458.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
--
Ron Wheeler
President
Artifact Software Inc
email: [email protected]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102