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

6337Passing a reference to a SOAP handler?

Expand Messages
  • Paul Dwerryhouse
    Jun 25, 2009
    • 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));


      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.



      Paul Dwerryhouse | PGP Key ID: 0x6B91B584