Loading ...
Sorry, an error occurred while loading the content.

Object Serialisation Issue

Expand Messages
  • Josh Glover
    Hello All, I am working on a SOAP::Lite client, using S::L 0.55. I frequently make use of this idiom: my $soap = SOAP::Lite - proxy( soapd:8080/soapd/ )
    Message 1 of 2 , Feb 10, 2004
    • 0 Attachment
      Hello All,

      I am working on a SOAP::Lite client, using S::L 0.55. I frequently make use
      of this idiom:


      my $soap = SOAP::Lite
      ->proxy( 'soapd:8080/soapd/' )
      ->uri( 'Foo/Bar' );

      my $bar = $soap->New->result;

      $bar->{key0} = "val0";
      $bar->{key1} = "val1";

      $soap->put( $bar );


      I am calling a constructor on the SOAP server, which returns me a Foo::Bar
      object. I fill in a few attributes and then "put" the object back into the
      persistence store on the server. This works like a charm. The serialiser
      produces the following envelope:


      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:namesp3="http://namespaces.soaplite.com/perl"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:namesp4="http://xml.apache.org/xml-soap"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp2:put xmlns:namesp2="Foo/Bar">
      <Foo__Bar xsi:type="namesp3:Foo__Bar">
      <key0 xsi:type="xsd:string">val0</key0>
      <key1 xsi:type="xsd:string">val1</key1>
      </Foo__Bar>
      </namesp2:put>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>


      The problem occurs when one of my attributes contains whitespace, e.g.

      $bar->{"Key 0"} = "Val 0";

      Then, S::L serialises my object like this:


      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      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/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp2:put xmlns:namesp2="Foo/Bar">
      <Foo__Bar xsi:type="apachens:Map">
      <item>
      <key xsi:type="xsd:string">Key 0</key>
      <value xsi:type="xsd:string">Val 0</value>
      </item>
      </Foo__Bar>
      </namesp2:put>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>


      This, of course, causes my server to break, since it gets a class name
      when it is expecting an object (i.e. a reference to a blessed hash).

      Now, to some degree, this is a "Doctor, it hurts when I do this." "Then
      stop doing that." problem, but I would like to know what is causing this
      behaviour. Is it part of the SOAP spec, or a bug in S::L's serialiser?

      TIA,
      Josh

      --
      Josh Glover <josh.glover@...>

      Software Engineer
      Twenty First Century Communications, Inc.
      http://www.tfcci.com/

      GPG keyID 0xF736E0E2 (4085 0B7F F8F5 CD7A 4405 AEF9 460B D8EA F736 E0E2)
      gpg --keyserver pgp.mit.edu --recv-keys F736E0E2
    • Duncan Cameron
      ... From: Josh Glover To: Sent: Tuesday, February 10, 2004 10:38 PM Subject: [soaplite] Object
      Message 2 of 2 , Feb 11, 2004
      • 0 Attachment
        ----- Original Message -----
        From: "Josh Glover" <josh.glover@...>
        To: <soaplite@yahoogroups.com>
        Sent: Tuesday, February 10, 2004 10:38 PM
        Subject: [soaplite] Object Serialisation Issue


        > Hello All,
        >
        > I am working on a SOAP::Lite client, using S::L 0.55. I frequently
        make use
        > of this idiom:
        >
        >
        > my $soap = SOAP::Lite
        > ->proxy( 'soapd:8080/soapd/' )
        > ->uri( 'Foo/Bar' );
        >
        > my $bar = $soap->New->result;
        >
        > $bar->{key0} = "val0";
        > $bar->{key1} = "val1";
        >
        > $soap->put( $bar );
        >
        >
        > I am calling a constructor on the SOAP server, which returns me a
        Foo::Bar
        > object. I fill in a few attributes and then "put" the object back into
        the
        > persistence store on the server. This works like a charm. The
        serialiser
        > produces the following envelope:
        >
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        > <SOAP-ENV:Envelope
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > xmlns:namesp3="http://namespaces.soaplite.com/perl"
        > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:namesp4="http://xml.apache.org/xml-soap"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > <SOAP-ENV:Body>
        > <namesp2:put xmlns:namesp2="Foo/Bar">
        > <Foo__Bar xsi:type="namesp3:Foo__Bar">
        > <key0 xsi:type="xsd:string">val0</key0>
        > <key1 xsi:type="xsd:string">val1</key1>
        > </Foo__Bar>
        > </namesp2:put>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        >
        > The problem occurs when one of my attributes contains whitespace, e.g.
        >
        > $bar->{"Key 0"} = "Val 0";
        >
        > Then, S::L serialises my object like this:
        >
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        > <SOAP-ENV:Envelope
        > 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/"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > <SOAP-ENV:Body>
        > <namesp2:put xmlns:namesp2="Foo/Bar">
        > <Foo__Bar xsi:type="apachens:Map">
        > <item>
        > <key xsi:type="xsd:string">Key 0</key>
        > <value xsi:type="xsd:string">Val 0</value>
        > </item>
        > </Foo__Bar>
        > </namesp2:put>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        >
        > This, of course, causes my server to break, since it gets a class name
        > when it is expecting an object (i.e. a reference to a blessed hash).
        >
        > Now, to some degree, this is a "Doctor, it hurts when I do this."
        "Then
        > stop doing that." problem, but I would like to know what is causing
        this
        > behaviour. Is it part of the SOAP spec, or a bug in S::L's serialiser?
        >
        Well, a space character is not allowed in an XML element name, so
        SOAP::Lite cannot serialise the key value of "Key 0" as an element.
        Given that, what is your server expecting a client to do?

        Regards

        Duncan Cameron
      Your message has been successfully submitted and would be delivered to recipients shortly.