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

Encoding of "&" and "<"

Expand Messages
  • shahada
    I encountered some weird problems with escaping the & (ampersand) and
    Message 1 of 3 , Apr 11, 2004
    • 0 Attachment
      I encountered some weird problems with escaping the "&" (ampersand)
      and "<" (lesser-than) characters. I am using SOAP-Lite 0.60 and Perl
      5.8.3, and viewing the encoded form with on_debug. In my Soap Client,
      whenever I do a:

      SOAP::Data->new (
      name => 'ping-text',
      value => 'hello < world'
      )

      I get it encoded as:

      <ping-text xsi:type="xsd:string">hello < world</ping-text>

      which is fine. But if I do a:

      SOAP::Data->new (
      name => 'ping-text',
      type => 'xsd:string',
      value => 'hello < world'
      )

      I get it encoded as:

      <ping-text xsi:type="xsd:string">hello < world</ping-text>

      which causes my server side to bomb out with a "Application failed
      during request deserialization:not well-formed (invalid token)" error.

      Is anybody else seeing this? Why is this, and is there a workaround
      other than not forcing the type?

      Regards,
      .sha
    • Rutger Wessels
      ... Hi, I had the same problem... The reason that it confuses the XML parser. I have a SOAP::Lite client that sends XML message to a server. My work-around is
      Message 2 of 3 , Apr 12, 2004
      • 0 Attachment
        shahada wrote:
        > I get it encoded as:
        >
        > <ping-text xsi:type="xsd:string">hello < world</ping-text>
        >
        > which causes my server side to bomb out with a "Application failed
        > during request deserialization:not well-formed (invalid token)" error.
        >
        > Is anybody else seeing this? Why is this, and is there a workaround
        > other than not forcing the type?

        Hi,

        I had the same problem... The reason that it confuses the XML parser. I
        have a SOAP::Lite client that sends XML message to a server.

        My work-around is a call to SOAP::Utils::encode_data explicitly,
        something like:

        $data = SOAP::Utils::encode_data('hello < world');

        print $data;

        Will give you 'hello < world'

        regards
        Rutger
      • Duncan Cameron
        ... SOAP::Lite doesn t automtically recognise the xsd:string value for a type, you simply need to use type = string and the value will be escaped properly
        Message 3 of 3 , Apr 12, 2004
        • 0 Attachment
          On 12-04-2004 at 04:54:10 shahada <shahada@...> wrote:

          >I encountered some weird problems with escaping the "&" (ampersand)
          >and "<" (lesser-than) characters. I am using SOAP-Lite 0.60 and Perl
          >5.8.3, and viewing the encoded form with on_debug. In my Soap Client,
          >whenever I do a:
          >
          >SOAP::Data->new (
          > name => 'ping-text',
          > value => 'hello < world'
          >)
          >
          >I get it encoded as:
          >
          ><ping-text xsi:type="xsd:string">hello < world</ping-text>
          >
          >which is fine. But if I do a:
          >
          >SOAP::Data->new (
          > name => 'ping-text',
          > type => 'xsd:string',
          > value => 'hello < world'
          >)
          >
          >I get it encoded as:
          >
          ><ping-text xsi:type="xsd:string">hello < world</ping-text>
          >
          >which causes my server side to bomb out with a "Application failed
          >during request deserialization:not well-formed (invalid token)" error.
          >
          >Is anybody else seeing this? Why is this, and is there a workaround
          >other than not forcing the type?

          SOAP::Lite doesn't automtically recognise the 'xsd:string' value for a type, you simply need to use
          type => 'string'

          and the value will be escaped properly and given the type that you want:
          xsi:type="xsd:string"

          This applies to the other xsd types, such a base64, too.

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