#82 Boolean serialization error


Boolean values ("true", "false") are not serialized
correctly; they are always serialized as "true".

Line 256 of SOAP/Lite.pm (version 0.65 beta 3) is
return [$name, {'xsi:type' => 'xsd:boolean', %$attr},
$value ? 'true' : 'false'];

I think it should be
return [$name, {'xsi:type' => 'xsd:boolean', %$attr}, lc
($value) eq 'true' ? 'true' : 'false'];


  • Martin Kutter

    Martin Kutter - 2007-10-02
    • priority: 5 --> 7
    • assigned_to: byrnereese --> kutterma
  • Martin Kutter

    Martin Kutter - 2007-10-02

    Logged In: YES
    Originator: NO

    That's a bit more difficult - actually, 'true' and 1 are true values, while 'false' and 0 are not.

    I ran across almost the same in SOAP::WSDL, recently...

    ... going to take SOAP::WSDL's code, as I know it works...

    return [ $name, { 'xsi:type' => 'xsd:boolean', %$attr}, ( $value eq 'true' or $value eq "1") ? 'true' : 'false' ];

    "TRUE" is actually false, even if just by misspelling.

    There's also an issue in the 1999 Serializer, which serializes bool values as (0|1). The spec actually says that (true|false) are allowed values...

    ... fixed in 1.45 in CVS.

  • Martin Kutter

    Martin Kutter - 2007-10-02
    • status: open --> closed-fixed
  • fyneman

    fyneman - 2007-10-02

    Logged In: YES
    Originator: YES

    Thanks for the fix! I agree 1 is 'true' and 0 is 'false'. However, values of 1 and 0 will be serialized as 'int' rather than 'boolean' before this line of code can be executed. In my application, I had to convert 0 to 'false' and 1 to 'true' in my data structure before serialization occurred in order to get it typed correctly.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks