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

Getting the Apache request object with S::L

Expand Messages
  • Joe Breeden
    All, I ve written a server using Apache 1.3.31, mod_perl 1.29 and SOAP::Lite v0.60 and my PerlHandler code looks like: my $server =
    Message 1 of 2 , Mar 31, 2005
    • 0 Attachment

      All,

       

      I’ve written a server using Apache 1.3.31, mod_perl 1.29 and SOAP::Lite v0.60 and my PerlHandler code looks like:

       

      my $server = SOAP::Transport::HTTP::Apache

                  ->dispatch_to(list of modules);

       

      sub handler { $server->handler(@_) }

       

      It works perfectly. I have clients written in .Net, Java and Perl accessing my objects. My question is how can I pass the apache request object into my packages? One thing I have to do now is read a configuration file with every call to a routine and I would like to include those settings as PerlSetVar directives in the httpd.conf file and use something like “my $dsn = $r->dir_config(‘dsn’) in my code instead of opening this config file with each access.

       

      Any help would be appreciated.

       

      Thanks in advance,

      Joe

      "This is the kind of movie that ends up playing on the TV set over the bar in a better movie."

       

    • Joe Breeden
      Randy, I guess I don t understand this as well as I thought. Below is my exact code (no editing for ease of reading). I haven t included my dispatched to
      Message 2 of 2 , Mar 31, 2005
      • 0 Attachment
        Randy,

        I guess I don't understand this as well as I thought. Below is my exact
        code (no editing for ease of reading). I haven't included my "dispatched
        to" package, but I could if necessary.

        In perl.conf:
        <Location /soap>
        SetHandler perl-script
        PerlHandler Soap
        </Location>

        In Soap.pm---------------
        package Soap;
        use strict;
        use SOAP::Transport::HTTP;

        use MM;
        use CM;
        use PM;

        my $server = SOAP::Transport::HTTP::Apache
        ->dispatch_to('MM', 'CM', 'PM');

        sub handler { $server->handler(@_) }

        1;


        My goes is be able to pass the apache object to something in the MM
        package as an argument. I guess I'm missing the part on sub-classing the
        SOAP::Transport::HTTP::Apache package.

        Thanks again for your help.
        Joe


        -----Original Message-----
        From: Randy J. Ray [mailto:rjray@...]
        Sent: Thursday, March 31, 2005 2:48 PM
        To: Joe Breeden
        Subject: Re: [soaplite] Getting the Apache request object with S::L

        > I've written a server using Apache 1.3.31, mod_perl 1.29 and
        SOAP::Lite
        > v0.60 and my PerlHandler code looks like:
        >
        > my $server = SOAP::Transport::HTTP::Apache
        > ->dispatch_to(list of modules);
        >
        > sub handler { $server->handler(@_) }
        >
        > It works perfectly. I have clients written in .Net, Java and Perl
        > accessing my objects. My question is how can I pass the apache request
        > object into my packages? One thing I have to do now is read a
        > configuration file with every call to a routine and I would like to
        > include those settings as PerlSetVar directives in the httpd.conf file
        > and use something like "my $dsn = $r->dir_config('dsn') in my code
        > instead of opening this config file with each access.

        What you need to do is subclass SOAP::Transport::HTTP::Apache, and
        overload the
        "handler" method. The overload would look roughly like this:

        sub handler
        {
        my ($self, $R, @args) = shift;

        # Do stuff with request obj $R

        $self->SUPER::handler(@args);
        }

        Then your PerlHandler code will need to get the request object and
        include it
        in the list of arguments to $server->handler().

        (I can't get much more specific without seeing the code itself, sorry.)

        Randy
        --
        rjray@... http://www.rjray.org
        http://www.svsm.org

        We will never have true civilization until we have learned to recognize
        the
        rights of others.-- Will Rogers
      Your message has been successfully submitted and would be delivered to recipients shortly.