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

4305Re: [soaplite] ... trying to derive from SOAP::Transport::HTTP::Daemon, new() method

Expand Messages
  • Duncan Cameron
    Jan 7, 2005
    • 0 Attachment
      On 2005-01-06 at 19:34:52 jmzorko wrote:

      >Hello, all ...
      >OK, i'm trying to expand my SOAP::HTTP::Transport::Daemon subclass,
      >with its' own new() method that will allow me to do other things.
      >However, i've not had good results so far (though i'm still trying).
      >I'm pretty new to Perl in general (perhaps a year or so, on and off),
      >so i'm sure i'm missing something simple.
      >Here is what i've got:
      >package EventBus;
      >use strict;
      >use SOAP::Lite;
      >use IO::Select;
      >use SOAP::Transport::HTTP;
      >use XML::Simple;
      >use Data::Dumper;
      >our @ISA = qw(SOAP::Transport::HTTP::Daemon);
      >sub new
      > print "new called\n";
      > my ($invocant, $target) = @_;
      > my $class = ref($invocant) || $invocant;
      > my %defaults = (Reuse => 1, LocalAddr => 'localhost', LocalPort
      > print "calling superclass ..."; # . Dumper( $class->SUPER );
      > #my $self = $class->SOAP::Transport::HTTP::Daemon::new(
      >%defaults );
      > my $self = $class->SUPER::new( %defaults );
      > bless $self, $class;
      > $self->dispatch_to('EventBus');
      > return $self;
      >... and here is the client:
      >use lib( "../../common/lib/perl" );
      >use strict;
      >use EventBus;
      >my $listener = new EventBus();
      >print "after new\n\n\n";
      >... what happens is this:
      >PugsleyButt:~/ctv/eng/issp/rmm/packagelistener jmzorko$ perl
      >new called
      >calling superclass ...new called
      >calling superclass ...new called
      >calling superclass ...new called
      >calling superclass ...new called
      >calling superclass ...new called
      >... so it's somehow looping, calling the EventBus::new() method
      >calls SOAP::HTTP::Transport::Daemon::new), ad infinitum. I am still
      >looking, but so far I really don't have a clue as to why this is
      Hi John

      There is an line of code in the SOAP::Transport::HTTP::Daemon package
      that causes your constructor to be reinvoked

      sub SSL {
      my $self = shift->new;
      @_ ? ($self->{_SSL} = shift, return $self) : return
      The first line is unnecessary, but it seems to be a common approach
      in SOAP::Lite, not too sure why.
      You can either remove the line or change your constructor to test
      whether the first parameter, $invocant in your case, is already a
      reference. See the new() method in SOAP::Transport::HTTP::Daemon
      itself for an example.

    • Show all 2 messages in this topic