Loading ...
Sorry, an error occurred while loading the content.

Passing a reference to a SOAP handler?

Expand Messages
  • Paul Dwerryhouse
    Hi all, Wondering if someone might be able to point me in the right direction on this. I ve written some SOAP::Lite server code which is being called from
    Message 1 of 1 , Jun 25, 2009
    View Source
    • 0 Attachment
      Hi all,

      Wondering if someone might be able to point me in the right direction on
      this. I've written some SOAP::Lite server code which is being called from
      Apache with mod-perl, and I'm trying to figure out how I can pass a
      database filehandle to the handler module, from the main mod-perl script.

      My code is as follows:

      File: /var/www/modperl/my-soap-handler
      ============================================================
      use SOAP::Transport::HTTP;

      $dbh = DBI->connect(...) if (! defined($dbh));

      SOAP::Transport::HTTP::CGI
      ->dispatch_to('MyClass::Handler')
      ->handle;
      ============================================================


      File: MyClass/Handler.pm
      ============================================================
      package MyClass::Handler;

      use SOAP::Lite;

      sub method {
      my $self = shift;
      my $envelope = pop;
      my $param = $envelope->dataof("//method//param")->value;

      ...

      [[do something with $dbh]
      }
      ============================================================

      Basically I want to connect to the database only once, not for every SOAP
      connection; if I make the connection to the database in MyClass::Handler,
      $dbh doesn't get retained between connections. If instead, I connect to the
      database in the my-soap-handler file, then it is retained between calls
      (as you would expect mod-perl to do), but I just can't work out a way to
      pass it to MyClass::Handler.

      Thanks muchly in advance for any advice.

      Cheers,

      Paul

      --
      Paul Dwerryhouse | PGP Key ID: 0x6B91B584
    Your message has been successfully submitted and would be delivered to recipients shortly.