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

Re: [soaplite] XML encoding a SOAP payload

Expand Messages
  • Paul Gallagher
    Hi Lev, you could use HTML::Entities. eg use HTML::Entities; ... my $payload = some data ; $data =
    Message 1 of 3 , Feb 16 3:58 PM
    • 0 Attachment
      Hi Lev, you could use HTML::Entities.
      eg

      use HTML::Entities;
      ...
      my $payload = '<?xml version="1.0" encoding="utf-8"?><block>some data</block>';
      $data =
      SOAP::Data->name("payload" =>
      encode_entities( $payload )
      );
      $som = $soap->call( SOAP::Data->name('Request') => $data );

      generates a request like this...

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:xsi= blah blah blah .... >
      <SOAP-ENV:Body>
      <Request>
      <payload xsi:type="xsd:string">
      &lt;?xml version=&quot;1.0&quot;
      encoding=&quot;utf-8&quot;?&gt;&lt;block&gt;some
      data&lt;/block
      &gt;
      </payload>
      </Request>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Regards,
      Paul
      On 2/15/07, Dave Howorth <dhoworth@...> wrote:
      > Lev Lvovsky wrote:
      > > Hello,
      > >
      > > I'm rather new to the SOAP world, so if this is a FAQ, please let me
      > > know.
      > >
      > > We're working with a SOAP method "Request", which requires that the
      > > payload (literally a block inside the "Request" block) be an XML
      > > encoded (> and <) block of text, like the following:
      > >
      > > ...headers...
      > > <Request>
      > > <payload >
      > > <?xml version="1.0" encoding="utf-8"?>
      > > <block></block>
      > > </payload>
      > > </Request>
      > >
      > > Putting together the XML message with the SOAP::Data package
      > > doesn't allow me to do this.
      > >
      > > Should I use an external Perl XML package to put together a valid bit
      > > of XML for this portion, or am I missing something fundamental?
      >
      > I believe you'll need to encode the XML yourself before giving it to
      > SOAP::Lite. It doesn't do anything itself, AFAIK.
      >
      > In my limited experience, the easiest way is to base64 encode it. I
      > posted a thread called "how to use base64" last August about how I did that.
      >
      > Cheers, Dave
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.