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

Passing data to the method being called

Expand Messages
  • goservus
    I would like to pass database connection handle and authentication status to the server s method being called. I m using SOAP::Lite in the mod_perl environment
    Message 1 of 5 , May 19, 2005
    • 0 Attachment
      I would like to pass database connection handle and authentication
      status to the server's method being called.

      I'm using SOAP::Lite in the mod_perl environment so it's impossible
      to
      use global variables to pass the data to the method.

      Every HTTP request is handled by my Apache/mod_perl framework that is
      responsible for establishing database connection, cheking
      authentication, parsing environment variables, and so on. All the
      information is stored in an object, which are passed to the final
      request handlers. This scheme worked well with the regular HTTP
      requests: I could pass this object to the handler.

      Now, then I'm attaching SOAP interface to this structure, I can't
      find
      a way to pass this object to the SOAP-related handlers.

      I've tried overloading function find_target which executes before
      final method. But anyway, I can't pass the data to it without using
      the global variables.

      Is there any way to do so?

      Thanks!
    • Jay A. Kreibich
      ... I ve done this with local vars (per-stack non-global globals (a non-global global is something that could only exist in perl)) but it can be trickily
      Message 2 of 5 , May 19, 2005
      • 0 Attachment
        On Thu, May 19, 2005 at 11:08:08AM -0000, goservus scratched on the wall:
        > I would like to pass database connection handle and authentication
        > status to the server's method being called.
        >
        > I'm using SOAP::Lite in the mod_perl environment so it's impossible
        > to use global variables to pass the data to the method.
        >
        > Every HTTP request is handled by my Apache/mod_perl framework that is
        > responsible for establishing database connection, cheking
        > authentication, parsing environment variables, and so on. All the
        > information is stored in an object, which are passed to the final
        > request handlers. This scheme worked well with the regular HTTP
        > requests: I could pass this object to the handler.
        >
        > Now, then I'm attaching SOAP interface to this structure, I can't
        > find
        > a way to pass this object to the SOAP-related handlers.
        >
        > I've tried overloading function find_target which executes before
        > final method. But anyway, I can't pass the data to it without using
        > the global variables.
        >
        > Is there any way to do so?

        I've done this with "local" vars (per-stack non-global globals
        (a "non-global global" is something that could only exist in perl))
        but it can be trickily since local vars are only valid when going up
        the stack. In my case I've got a global dispatch routine that all
        incoming requests goes through, so it was the logical place to
        declare the vars, but there often isn't a very good place to put
        that kind of thing in the call stack.

        -j

        --
        Jay A. Kreibich | CommTech, Emrg Net Tech Svcs
        jak@... | Campus IT & Edu Svcs
        <http://www.uiuc.edu/~jak> | University of Illinois at U/C
      • Andrey Yurin
        ... I m afraid, it s impossible to use the local vars in my case :( I ve found that there is a possible way to pass the variable by modifying
        Message 3 of 5 , May 19, 2005
        • 0 Attachment
          >
          > I've done this with "local" vars (per-stack non-global globals
          > (a "non-global global" is something that could only exist in perl))
          > but it can be trickily since local vars are only valid when going up
          > the stack. In my case I've got a global dispatch routine that all
          > incoming requests goes through, so it was the logical place to
          > declare the vars, but there often isn't a very good place to put
          > that kind of thing in the call stack.
          >

          I'm afraid, it's impossible to use the local vars in my case :(
          I've found that there is a possible way to pass the variable by
          modifying SOAP::SOM::paramsin method somehow so that it will return my
          variable. But is a very dirty, i think. Anyway, I even don't know how
          to do this things right. It's just an assumption.

          I'm slightly surprised, that I still haven't found a standard and
          flexible scheme/method that allows create a dispatcher for SOAP
          requests in the mod_perl environment. Anyway, I think it would be
          tricky. All the possible ways are based on using inheritance, which is
          not great in a mod_perl environment. Perhaps, I don't see evident? :)
        • Jay A. Kreibich
          ... Or any other environment, for that matter. For all the dispatch methods available, I still wish there was a dispatch_thru or something similar that just
          Message 4 of 5 , May 19, 2005
          • 0 Attachment
            On Thu, May 19, 2005 at 10:56:45PM +0400, Andrey Yurin scratched on the wall:

            > I'm slightly surprised, that I still haven't found a standard and
            > flexible scheme/method that allows create a dispatcher for SOAP
            > requests in the mod_perl environment.

            Or any other environment, for that matter. For all the dispatch
            methods available, I still wish there was a "dispatch_thru" or
            something similar that just sent everything to one class. Put a
            AUTOLOAD function in there and you can write your own dispatcher.
            Simple, neat, easy. But it isn't there, so rather I dispatch into a
            series of classes that all have three lines:

            ----------------------------------------------------------------------
            package YetAnotherExposedWebServicesClass
            our( @ISA ) = ( 'WebServicesBaseClass' );
            1;
            ----------------------------------------------------------------------

            And then the base class has an AUTOLOAD function and nothing else.
            That AUTOLOAD function does my auth/auth stuff and some other
            book-keeping that is done with each transaction, and then dispatches
            the call to the correct shadow class (e.g.
            "YetAnotherExposedClass::WebServices"), which in turn layers on top
            of "YetAnotherExposedClass".

            Ugly, but it gives me what I want. Most of the smaller stub files
            are built automatically by the build environment, as well as
            everything going into a file that pre-loads all the classes into the
            mod_perl environment so you don't have to worry about all kinds of
            "use" statements.

            > Anyway, I think it would be
            > tricky. All the possible ways are based on using inheritance, which is
            > not great in a mod_perl environment. Perhaps, I don't see evident? :)

            Why don't you consider inheritance a good idea mod_perl? About the
            only thing that gets tricky in mod_perl is treads (or, rather,
            multiple environments) and that shouldn't effect inheritance. Or am
            I missing something?

            -j

            --
            Jay A. Kreibich | CommTech, Emrg Net Tech Svcs
            jak@... | Campus IT & Edu Svcs
            <http://www.uiuc.edu/~jak> | University of Illinois at U/C
          • Andrey Yurin
            ... Thanks for describing this method! Perhaps, I try to implement them if there wouldn t be another one that won t require modifying my framework. ... As far
            Message 5 of 5 , May 19, 2005
            • 0 Attachment
              > And then the base class has an AUTOLOAD function and nothing else.
              > That AUTOLOAD function does my auth/auth stuff and some other
              > book-keeping that is done with each transaction, and then dispatches
              > the call to the correct shadow class (e.g.
              > "YetAnotherExposedClass::WebServices"), which in turn layers on top
              > of "YetAnotherExposedClass".

              Thanks for describing this method! Perhaps, I try to implement them if
              there wouldn't be another one that won't require modifying my
              framework.


              > > Anyway, I think it would be
              > > tricky. All the possible ways are based on using inheritance, which is
              > > not great in a mod_perl environment. Perhaps, I don't see evident? :)
              >
              > Why don't you consider inheritance a good idea mod_perl? About the
              > only thing that gets tricky in mod_perl is treads (or, rather,
              > multiple environments) and that shouldn't effect inheritance. Or am
              > I missing something?

              As far as I know, inheritance greatly increases the memory consumption
              per each Apache child. It's very critical for heavy loaded sites.
            Your message has been successfully submitted and would be delivered to recipients shortly.