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

I'm trying to send XML as a SOAP variable but the <'s are being encoded to <

$service = SOAP::Lite -> uri('http://whatever/DSAccountService.asmx/') -> proxy('http://whatever/DS +AccountService.asmx'); $xml = "<test>poo</test>"; my $result = $service->AddAccount( xml => $xml} );
but the SOAP call is encoding it to...

&lt;test>poo&lt;/test>

Any idea's how to stop this?

Replies are listed 'Best First'.
Re: SOAP::Lite encoding xml
by szbalint (Friar) on Aug 02, 2007 at 15:36 UTC
    I think the encoding is an intended feature, otherwise you couldn't transport things that are considered as a variable by SOAP. Without proper encoding your xml would be considered part of the XML structure that SOAP uses to implement itself.

    If you want to manually edit part of the SOAP xml that goes out, you need to do
    my $raw = SOAP::Data->type(xml => $xml);

    ...and pass that to the service method call. The xml needs to be correct and conforming to the SOAP specification, so beware.
Re: SOAP::Lite encoding xml
by spatterson (Pilgrim) on Aug 02, 2007 at 16:38 UTC
    setting $SOAP::Constants::DO_NOT_USE_XML_PARSER = 1; should turn parsing of xml where the xml is one of your data entries.

    just another cpan module author
Re: SOAP::Lite encoding xml
by rahed (Scribe) on Aug 07, 2007 at 13:23 UTC
    You can encode any characters within xml and they will be transported as they are if the data is encoded as cdata:
    <![CDATA[ your string <one>aaa</one> ]]>