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

I'm having a difficult time understanding why using DBI is causing a SOAP module to not work. When I use DBI in a module and restart the SOAP server, function calls return nothing but undef results (I'm assuming what's happening is the soap server couldn't dispatch the module). When I comment out the use DBI and all my DBI code in my module and restart the server it works fine. Here's a stripped down example that shows the problem.

Client:
#!/usr/bin/perl use strict; use warnings; use SOAP::Lite; my $soap = SOAP::Lite->uri('http://localhost/Test')->proxy('http://loc +alhost:8089/'); print 'Returned: ', $soap->return1()->result(), "\n";

Soap Server:
#!/usr/bin/perl use strict; use warnings; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::Daemon -> new (LocalPort => 8089, Reuse => 1) -> dispatch_to('/opt/scripts/SOAP/lib') -> handle;

Module:
package Test; use DBI; sub return1 { return 1; } 1;

This code works fine when "use DBI;" is commented, returning 1. When uncommented it returns undef.
Any thoughts? I've googled around for SOAP::Transport and DBI issues and have seen some folks with not-so-similar problems but nothing matching my own. I'm new to using SOAP but have successfully implemented scripts that don't use DBI.

EDIT: I should also add that DBI works fine on this box in a non-soap environment. This script works fine with use DBI commented or not in the module.

#!/usr/bin/perl use strict; use warnings; use lib '/opt/scripts/SOAP/lib'; use Test; print Test::return1(), "\n";

Replies are listed 'Best First'.
Re: Soap::Transport::HTTP vs DBI
by Corion (Patriarch) on Jul 02, 2010 at 15:53 UTC

    Have you tried tracing what actually happens, by using SOAP::Trace respectively

    SOAP::Lite->import(+trace => all => -result => -parameters);

    ?

      It looks like the useful lines from trace=>all are:

      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error

      and
      <faultcode>soap:Client</faultcode><faultstring>Denied access to method + (return1) in class (Test) at /usr/lib/perl5/site_perl/5.8.5/SOAP/Lit +e.pm line 2731. </faultstring>

      So the HTTP daemon is giving an internal server error. Is there some similar debugging code I can use on the SOAP::Transport::HTTP::Daemon?
        Regarding the docs "access denied" is thrown when the called class is not available in the path given to dispatch_to. DYNAMIC_DEPLOYMENT_EXAMPLE
Re: Soap::Transport::HTTP vs DBI
by jethro (Monsignor) on Jul 02, 2010 at 16:18 UTC
    Could it be that loading of DBI fails only from the webserver? Try to make a simple website CGI script (the usual "hello world") and then add 'use DBI'. If you don't see "hello world" on the web page anymore, the fault lies in the environment of your webserver
      The normal apache web server on this box from which I run CGI scripts often can access DBI fine. I suppose whether SOAP::Transport::HTTP::Daemon can access it is the question and I'm not sure how to answer.