#49 SOAP::Data as key of struct doesn't serialize properly

0.60
closed-invalid
5
2014-08-14
2004-09-21
No

It ends up with "SOAP::Data=HASH..." in the serialized
XML.

Test program:

use SOAP::Lite;

$s = new SOAP::Server();
$x = SOAP::Data->type("string" => "344.1");

print $s->serializer->serialize([$x, 3]), "\n";
print $s->serializer->serialize({$x => 3}), "\n";

Output:

[olson@yips SOAP-Lite-0.60]$ perl tsoap
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENC:
Array xmlns:xsi="http://www.w3.org/1999/XMLSchema-
instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/
soap/encoding/" xmlns:SOAP-ENV="http://schemas.
xmlsoap.org/soap/envelope/" xsi:type="SOAP-ENC:Array"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
ENC:arrayType="xsd:ur-type[2]"><item xsi:type="xsd:
string">344.1</item><item xsi:type="xsd:int">3</item></
SOAP-ENC:Array>
<?xml version="1.0" encoding="UTF-8"?><c-gensym1
xmlns:xsi="http://www.w3.org/1999/XMLSchema-
instance" xmlns:apachens="http://xml.apache.org/xml-
soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/
soap/encoding/" xmlns:SOAP-ENV="http://schemas.
xmlsoap.org/soap/envelope/" xsi:type="apachens:Map"
xmlns:xsd="http://www.w3.org/1999/
XMLSchema"><item><key xsi:type="xsd:string">SOAP::
Data=HASH(0x82256e8)</key><value xsi:type="xsd:
int">3</value></item></c-gensym1>

Discussion

  • Robert Olson

    Robert Olson - 2004-09-21

    Test script

     
  • Byrne Reese

    Byrne Reese - 2004-09-27

    Logged In: YES
    user_id=28043

    I have been looking into this bug and it appears that an
    ordered hash expects to get hash keys and values that are
    SCALARs, not SOAP::Data structures. I see the logic in
    supporting SOAP::Data structures though - I will see if I
    can't come up with a solution.

     
  • Robert Olson

    Robert Olson - 2004-09-27

    Logged In: YES
    user_id=20112

    Cool. The reason I need the SOAP::Data here is that I'm
    passing strings around that are in the form "83333.1" which
    otherwise get serialized as floating-point numbers ...

     
  • Martin Kutter

    Martin Kutter - 2007-11-08

    Logged In: YES
    user_id=884175
    Originator: NO

    SOAP::Data objects don't serialize to their value on stringification (which is almost what using them as a hash key is), and hash keys in perl are expected to be scalars (not references - acually hash keys are not even full-blown scalars, but something like castrates).
    So, the described behaviour is perfectly legal.

    The proper solution is creating a custom serializer and overwriting the as_float (or assigning a type to the SOAP::Data object so SOAP::Lite doesn't have to guess...).

     
  • Martin Kutter

    Martin Kutter - 2007-11-08
    • status: open --> closed-invalid
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks