4 April 2006

SOAP::Lite tip

Sorry for the narrow technical scope of this article, but I spent some time searching for the solution to this SOAP::Lite error:

duplicate attribute at line 1, column 454, byte 454 at C:/matt/opt/perl/site/lib/XML/Parser.pm line 187

The problem is that SOAP::Lite versions earlier than 0.65 used the 1999 XML Schema by default. This schema is broken, and the Apache Axis SOAP server (and probably others) have a different interpretation to SOAP::Lite of what is valid markup. In Perl, you need to configure SOAP::Lite to use the 2001 schema like this:

my $svc = SOAP::Lite->service('http://example.com/soap-axis/remoteservice.wsdl');
$svc->xmlschema('http://www.w3.org/2001/XMLSchema');

Then, presto, all transmissions are done in the 2001 schema, and the XML parser is happy.

You could also upgrade to SOAP::Lite version 0.65 or greater, since the default schema is now the 2001 one. However, version 0.55 is still the latest package for ActivePerl, which is why this was a problem for me.

Update 29/4: fixed typo in the code sample.