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

Re: [soaplite] object method call problem

Expand Messages
  • Paul Kulchenko
    Hi, Joerg! Steve is absolutely right, it should work, but it might defeat the purspose of specifying modules explicitely in dispatch_to() method. You have only
    Message 1 of 6 , May 21, 2001
    • 0 Attachment
      Hi, Joerg!

      Steve is absolutely right, it should work, but it might defeat the
      purspose of specifying modules explicitely in dispatch_to() method.
      You have only two choices:
      1. you load modules yourself, directly (with 'use MODULE' in your
      server code) or indirectly ('use/require' in your module) and ALLOW
      SOAP server to dispatch calls there providing NAMES of those modules
      in dispatch_to() calls, either in full or with regexp.
      2. you do NOT load modules, but specify directory(ies), then ALL
      that SOAP processor will load from those directories will be allowed
      to be accessed, but SOAP processor needs to load them itself.

      You want to load it youself, but do not specify the name. You can
      follow Steve's advice, but in THAT case user will be able to access
      LWP::UserAgent, "system" or any other module on your system. I bet it
      isn't something you want. That's the way you should either list all
      modules you want to give access to, or at least limit those mask to
      something more meaningfull.

      At the same time, dispatch_to() list isn't something static. You can
      manipulate it if you want:

      # server code

      my $server = SOAP::Transport::HTTP::Daemon
      .....
      ;

      package Manipulate::Server;

      sub add {
      shift;
      $server->dispatch_to($server->dispatch_to, @_);
      }

      later in your module code you can do something like:

      sub new {
      ......
      Manipulate::Server->add('MyClass');
      bless {} => 'MyClass';
      }

      Code is incomplete, but you got the idea. I didn't try it, but don't
      see any reason why it shouldn't work.

      > > P.s.: The first example works for me even if I don't specify the
      > > package explicitely:
      > >
      > > uri => 'http://www.soaplite.com/',
      > >
      > > instead of
      > >
      > > uri => 'http://www.soaplite.com/A',
      > >
      > > Is that intended?
      Yes, autodispatch will specify class for (as PATH of URI) you even
      you don't. That's why this piece works with autodispatch and for OO
      you need to specify it manually. Tradeoff between flexibility and
      convenience :)

      Best wishes, Paul.

      --- Steve McKay <smckay@...> wrote:
      > If I understand your question correctly, we are getting around
      > specifying
      > each module individually by using the following dispatch_to line in
      > our
      > server:
      >
      > ->dispatch_to('/opt/soap/lib','[\w:]+');
      >
      > All of our perl modules live in /opt/soap/lib. The regex matches
      > any module
      > that contain words and allows the server to execute them. This
      > will also
      > traverse sub-directories in /opt/soap/lib in looking for modules.
      >
      > Hope that helps.
      >
      > Steve McKay.
      >
      >
      >
      >
      >
      > joerg.ziefle@... wrote:
      >
      > > Thanks for the extensive answer and examples, Paul!
      > >
      > > Your code works for me indeed. But what I forgot to mention in
      > my
      > > posting was that I don't want to hardcode the modules in the
      > dispatch_to
      > > method (as in your examples). My dispatch_to call just specifies
      > the
      > > directory in which my modules are placed.
      > >
      > > I have
      > >
      > > -> dispatch_to('/dir/to/perl/modules/')
      > >
      > > instead of
      > >
      > > -> dispatch_to('A', 'B')
      > >
      > > And if I do that, it doesn't work again. :(
      > >
      > > So, is there a way of keeping the flexibility of dynamic
      > autodispatching
      > > but being able to do the "subobject" method calls?
      > >
      > > It turns out that I get the error:
      > >
      > > Denied access to method (mass) in class (Mass) at
      > > /u0/gt4556a/perl/SOAP/Lite.pm line 1498.
      > >
      > > on the call
      > >
      > > print $beam->mass->mass;
      > >
      > > where $beam->mass returns a Mass object (this is verified with
      > > Data::Dumper) and the second mass call is a method of the
      > returned Mass
      > > object.
      > >
      > > The situation doesn't change if I choose two different names for
      > the
      > > methods, so a name clash can't be the reason.
      > >
      > > I have put the minimalized code at the following address for
      > further
      > > inspection:
      > >
      > > Server:
      > >
      > > http://www.normans.isd.uni-stuttgart.de/~ziefle/soap/daemon.plx
      > >
      > > Client:
      > >
      > >
      >
      http://www.normans.isd.uni-stuttgart.de/~ziefle/soap/abeamclient.plx
      > >
      > > Modules:
      > >
      > > (main object, contains Mass object)
      > > http://www.normans.isd.uni-stuttgart.de/~ziefle/soap/Beam.pmx
      > >
      > > (contains the mass() method that fails for dynamic
      > autodispatching)
      > > http://www.normans.isd.uni-stuttgart.de/~ziefle/soap/Mass.pmx
      > >
      > > Thanks,
      > >
      > > J�rg
      > >
      > > P.s.: The first example works for me even if I don't specify the
      > > package explicitely:
      > >
      > > uri => 'http://www.soaplite.com/',
      > >
      > > instead of
      > >
      > > uri => 'http://www.soaplite.com/A',
      > >
      > > Is that intended?
      > >
      > > To unsubscribe from this group, send an email to:
      > > soaplite-unsubscribe@yahoogroups.com
      > >
      > >
      > >
      > > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >


      __________________________________________________
      Do You Yahoo!?
      Yahoo! Auctions - buy the things you want at great prices
      http://auctions.yahoo.com/
    Your message has been successfully submitted and would be delivered to recipients shortly.