estoque has asked for the wisdom of the Perl Monks concerning the following question:

Good Day! Basically I need to encode the whole body of an XML into an HTML-safe string.

Needed Body:
<SOAP-ENV:Body> <tns1:receive xmlns:tns1="http://eBonding/taservice/callback">&lt;?xml + version="1.0"?&gt; &lt;tML-TA:RequestTroubleReportCreationResponse xmlns:tML-TA="http://w +ww.ansi.org/tML/TA/tML-TA" xmlns:tML-TABase="http://www.ansi.org/tML/ +TA/tML-TABase"&gt; &lt;/tML-TA:RequestTroubleReportCreationResponse&gt;</tns1:receive> </SOAP-ENV:Body> <br><br>
Generated body:
<SOAP-ENV:Body> <tns1:receive xmlns:tns1="http://eBonding/taservice/callback"><?xml ve +rsion="1.0"?> <tML-TA:RequestTroubleReportCreationResponse xmlns:tML-TA="http://www. +ansi.org/tML/TA/tML-TA" xmlns:tML-TABase="http://www.ansi.org/tML/TA/ +tML-TABase"> </tML-TA:RequestTroubleReportCreationResponse></tns1:receive>


I already tried searching but their issue is the other way, conversion of escaped characters to the character itself(< to <).

Can you point me to the right direction on this.

Replies are listed 'Best First'.
Re: SOAP: Escaping whole body
by Anonymous Monk on Jan 22, 2016 at 01:38 UTC

    Good luck with Re^4: SOAP: Escaping whole body

    #!/usr/bin/perl -- use SOAP::Lite +trace => 'debug', readable => 1; #construct of soap data parameters my $soap = SOAP::Lite -> ns('http://eBonding/taservice/callback','tns1') -> autotype(0) -> proxy('https://url') ; my $data = SOAP::Data->name('RequestTroubleReportCreationResponse' => +[])->prefix("tML-TA")->attr({'xmlns:tML-TA'=>'http://www.ansi.org/tML +/TA/tML-TA','xmlns:tML-TABase'=>'http://www.ansi.org/tML/TA/tML-TABas +e'}); my $serial = $soap->serializer; my $xml = $serial->xmlize( $serial->encode_object( $data ) ) ; $xml = SOAP::Utils::encode_data( $xml ); $xml = SOAP::Data->type('xml' => $xml ); $soap->receive( $xml ); __END__ SOAP::Transport::HTTP::Client::send_receive: POST https://url HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 994 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://eBonding/taservice/callback#receive" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://eBonding/taservice/callback" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <tns1:receive> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;tML-TA:RequestTroubleReportCreationResponse xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tML-TA="http://www.ansi.org/tML/TA/tML-TA" xmlns:tML-TABase="http://www.ansi.org/tML/TA/tML-TABase" xmlns:tns1="http://eBonding/taservice/callback" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /&gt; </tns1:receive> </soap:Body> </soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to url: +443 Content-Type: text/plain Client-Date: Fri, 22 Jan 2016 01:45:02 GMT Client-Warning: Internal response Can't connect to url:443 nodename nor servname provided, or not known at C:/perl/site/lib/LWP/P +rotocol/http.pm line 47. 500 Can't connect to url:443 at soap-body-escape-1153240.pl line 23.
      Wow, thank you for this. I will test this on my end.
Re: SOAP: Escaping whole body
by Anonymous Monk on Jan 21, 2016 at 08:06 UTC

    Can you point me to the right direction on this.

    No. What module are you using?

      I am using SOAP::Lite
        So, what call generated that xml thats not quite what you're after (show some code)?