Problem with SOAP::Lite and Escaping Characters

Tom Hukins tom at eborcom.com
Tue Jun 5 03:15:08 PDT 2007


I'm fairly new to SOAP and have encountered a problem with characters
that need escaping in XML.

I've tracked down the problem to this code:
  foreach my $key (keys %in) {
      push @elems, SOAP::Data->name($key => $in{$key})
          ->type($type{$key});
  }

%in contains key/value pairs that I want to serialise in the request
and %type contains a set of mappings for data types associated with
each key.

Everything works wonderfully until I pass in something with a value
containing an '&'.  SOAP::Lite doesn't escape this, and it seems not
to escape other special characters such as '<'.  If I replace these
with escaped versions, such as '&amp;' and '&lt;', everything works.

I could manually process the keys in %in, but I wondered if I can get
SOAP::Lite to do this for me.  Or have I missed a better approach?

Tom


More information about the MiltonKeynes-pm mailing list