Perl SOAP::Lite Adding CDATA

200 views Asked by At

I am calling a web service using SOAP::Lite module as follows:

my $som = $soap->call('ns:xxx' =>
           (
            SOAP::Data->name('ns:data' =>
            \SOAP::Data->value(
               SOAP::Data->name('username')->type('')->value($username),
             )
          )
      )
  );

It did not work. So I called web service using SOAPUI tool to see xml structure.

Then I run my code at debug mode (use SOAP::Lite 'debug'), see created xml and compared with the xml of SOAPUI tool. The only difference is that SOAPUI xml contains CDATA tag as follow:

<![CDATA[
   xml
]]>

I searched and saw that CDATA is used to prevent error caused by special characters

How can I add this tag using Perl code?

1

There are 1 answers

2
rahed h On

Use XML::Generator to encode the CDATA section. Then put it in the relevant soap structure.