In my work going through the SOAP::Lite code base fixing bugs and what not, I ran across an old email thread on the newsgroup asking about a fault that their client kept receiving from a SOAP Server written in Perl:
Failed to access class (Majordojo:TemperatureService):
syntax error at (eval 123) line 1, near "require Majordojo:"
The root of the problem stems from the fact that the SOAP Action header, and/or the namespace of the method being invoked uses a URI format that confuses SOAP::Lite. In this case the URI is urn:Majordojo:TemperatureService. SOAP::Lite is not crazy about this format because when it tries to import the module Majordojo:TemperatureService it fails because it is not a valid module name. The call was failing because the server written in Perl was using SOAP::Lite default dispatch methodology, or the simplistic dispatch-to() subroutine.
The problem is fixed by using the SOAP::Lite->dispatch-with() subroutine on the server. Pass to this subroutine a HASH reference containing a map of URIs to Modules that will handle the request. For example, in the example above, you can dispatch a request to any URI you choose to any module you choose using code similar to below:
SOAP::Transport::HTTP::CGI
->dispatch_with({ 'urn:Majordojo:TemperatureService' => 'TemperatureService' })
->handle;
It is easy to use a single CGI to handle dispatching request to all of your Web services. For example, the code above can easily be extended to dispatch requests to any number of services:
SOAP::Transport::HTTP::CGI
->dispatch_with( { 'urn:Majordojo:TemperatureService' => 'TemperatureService',
'http://majordojo.com/services/foo' => 'Majordojo::Foo',
'http://majordojo.com/services/lwp' => 'LWP'})
->handle;
Comments