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

712RE: [soaplite] General Question

Expand Messages
  • Paul Kulchenko
    Aug 1, 2001
    • 0 Attachment
      Hi, David!

      > Thanks for the help... I'm having trouble with the statement:
      >
      > die "No such method...\n" unless exists $%methods_map{$method};
      should be:

      die "No such method...\n" unless exists $methods_map{$method};

      I didn't test it, just typed out of my head.

      > Since I'm new to perl, I'm not sure what the problem is. It works
      I advise you to stay with more simple case (access from your client
      only classes/methods you really have on server) and then move toward
      more complex case you discussed.

      Best wishes, Paul.

      --- David Mullens <damullens@...> wrote:
      > Hi,
      >
      > Thanks for the help... I'm having trouble with the statement:
      >
      > die "No such method...\n" unless exists $%methods_map{$method};
      >
      > It seems to be $%methods_map{$method} that is causing the trouble.
      > I get
      > the error: Bareword found where operator expected at
      > ./MainInterface.cgi
      > line 21, near "$%methods_map"
      > (Missing operator before methods_map?)
      >
      > Since I'm new to perl, I'm not sure what the problem is. It works
      > fine if I
      > put it in the die "No.....$%methods_map{$method}"..... statement.
      >
      > Thanks for the help.
      >
      > DAve.
      >
      >
      >
      > -----Original Message-----
      > From: soaplite@yahoogroups.com [mailto:soaplite@yahoogroups.com]
      > Sent: Tuesday, July 31, 2001 8:44 PM
      > To: soaplite@yahoogroups.com
      > Subject: Re: [soaplite] General Question
      > Importance: Low
      >
      >
      > Hi, David!
      >
      > >> I'm wanting to have several small scripts (modules) called from
      > a
      > >> large main
      > it IS definitely possible. Yet I'm not sure that is right approach.
      > Combination of URI and method will tell you what module/method to
      > use. You want to fix URI and map method to different combinations
      > of
      > module/method on server side. Doable, but I'd rather create one
      > AUTOLOAD function and build it dynamically from hash:
      >
      > use SOAP::Transport::HTTP;
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to('MainInterface')
      > -> handle;
      >
      > package MainInterface;
      >
      > use vars qw($AUTOLOAD);
      >
      > my %methods_map = (
      > method1 => ['package', 'method'],
      > method2 => ['package', 'method1'],
      > );
      >
      > sub AUTOLOAD {
      > my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
      > return if $method eq 'DESTROY';
      >
      > die "No such method...\n" unless exists $%methods_map{$method};
      > my($package, $method) = @{$methods_map{$method}};
      > eval "require $package" or die;
      > # little trick that allows you to implement
      > # method (OO) rather than function calls
      > $method = "${package}::$method";
      > shift->$method(@_);
      > # don't forget that first parameter is class/object
      > # shift it if you don't need that
      > }
      >
      > All other modules can be implemented in usual fashion.
      >
      > >> In the Methods module, I would have
      > >>
      > >> use SOAP::Transport::HTTP;
      > >> SOAP::Transport::HTTP::CGI
      > >> -> dispatch_to('Modules')
      > >> -> handle;
      > you don't need that in Methods module, only usual module code.
      >
      > >> Is this possible? Right now I'm getting an access denied.
      > Access denien where? Could you provide request/response payload if
      > you still have problems? Hope it helps.
      >
      > Best wishes, Paul.
      >
      > --- David Mullens <damullens@...> wrote:
      > >> Hi,
      > >>
      > >> I'm wanting to have several small scripts (modules) called from
      > a
      > >> large main
      > >> script. The main script would basically have:
      > >>
      > >>
      > >> use SOAP::Transport::HTTP;
      > >> SOAP::Transport::HTTP::CGI
      > >> -> dispatch_to('MainInterface')
      > >> -> handle;
      > >>
      > >> package MainInterface;
      > >>
      > >> use Methods;
      > >>
      > >> sub methodName {
      > >> &Methods::method_Name;
      > >> }
      > >>
      > >>
      > >>
      > >> In the Methods module, I would have
      > >>
      > >> use SOAP::Transport::HTTP;
      > >> SOAP::Transport::HTTP::CGI
      > >> -> dispatch_to('Modules')
      > >> -> handle;
      > >>
      > >> sub method_Name {
      > >> # some type of logic here
      > >>
      > >> return $whatever;
      > >> }
      > >>
      > >>
      > >> For each subroutine in the main script, there would be a module.
      > >>
      > >> The reason why we are wanting to implement SOAP this way, is so
      > we
      > >> can
      > >> setup the endpoint url in a database (or java properties file)
      > and
      > >> the
      > >> person programming the client won't have to worry about
      > different
      > >> endpoints,
      > >> only the method to call. We can create new modules, then enter
      > >> them in our
      > >> main endpoint script. The main script will take care of the
      > call.
      > >>
      > >> When ever something needs to be updated, we don't have to touch
      > the
      > >> main
      > >> endpoint script at all. We can edit whatever module we want.
      > >> There is a
      > >> chance that we will have 200 or so modules when all is
      > finished.
      > >>
      > >> Is this possible? Right now I'm getting an access denied.
      > >>
      > >> Is this the best way to implement things? We really don't want
      > one
      > >> script
      > >> with 200 subroutines (at least with all the logic) and we don't
      > >> want one
      > >> script for each endpoint. We thought if we implement it with
      > one
      > >> main
      > >> script calling different modules, it would be easier to
      > maintain.
      > >>
      > >>
      > >>
      > >> Thanks for any suggestions,
      > >>
      > >> Dave.
      > >>
      > >>
      > >> ------------------------ Yahoo! Groups Sponsor
      > >>
      > >> 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!?
      > Make international calls for as low as $.04/minute with Yahoo!
      > Messenger
      > http://phonecard.yahoo.com/
      >
      >
      > 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/
      >
      >
      >
      >
      >
      === message truncated ===


      __________________________________________________
      Do You Yahoo!?
      Make international calls for as low as $.04/minute with Yahoo! Messenger
      http://phonecard.yahoo.com/
    • Show all 5 messages in this topic