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

Simple version of yesterdays problem: autodispatch works, but other method doesnt...

Expand Messages
  • Joe Landman
    Ok, got this one down to a really simple test code, with 1 server code and 2 clients. Client 1 uses the normal method of doing things (normal for me, been
    Message 1 of 2 , Mar 14 12:10 PM
      Ok, got this one down to a really simple test code, with 1 server code
      and 2 clients. Client 1 uses the "normal" method of doing things
      (normal for me, been using them for ~6 months). Client 2 uses
      autodispatch.

      Client 2 works, client 1 does not. I am not sure if this is a
      programming bug (me), or a SOAP::Lite bug (not me). Any thoughts?

      Fromt the output, it appears as if new is never called using client 1.
      That is, it is called, but never makes it to the server. The call from
      client 2 not only makes it, but warns of an AUTOLOADed main::new.

      ----

      Client 1 (client.pl)

      #!/usr/bin/perl -w

      use strict;
      use Carp;
      use SOAP::Lite ;
      use Data::Dumper;

      my ($soap);


      #
      # create a new object
      #
      print "\n\ncreating object\n\n";
      $soap = SOAP::Lite
      -> uri('http://localhost/simple')
      -> proxy('http://localhost:12345');

      print "\n\n\tcalling new ...\n\n";
      $soap -> new('attribute_1'=>54321,'attribute_2'=>12321);


      print "\n\n\tcalling burp ...\n\n";
      my $date=$soap->burp()->result;
      print "burp date =",$date,"\n";


      client 2 (client2.pl):

      #!/usr/bin/perl -w

      use strict;
      no strict "subs";
      use Carp;
      use SOAP::Lite
      +autodispatch
      => uri => 'http://localhost/simple',
      proxy => 'http://localhost:12345' ;

      use Data::Dumper;

      my ($soap,$rc);


      #
      # create a new object
      #
      print "\n\ncreating object\n\n";

      $rc=new('attribute_1'=>54321,'attribute_2'=>12321);

      print "rc=",Dumper(\$rc),"\n";

      print "\n\n\tcalling burp ...\n\n";
      my $date=$rc->burp();
      print "burp date =",$date,"\n";

      server (server.pl)

      #!/usr/bin/perl -w


      use strict;
      use SOAP::Lite;
      use SOAP::Transport::HTTP;

      my $daemon= SOAP::Transport::HTTP::Daemon
      -> new (
      LocalPort => 12345,
      Listen => 10,
      Reuse => 1
      )
      ->dispatch_to('simple');
      print "Waiting ...... \n\n";
      $daemon->handle;

      package simple;


      $simple::VERSION=1.0;
      use strict;
      use Data::Dumper;
      use Carp;
      use diagnostics;

      #our (@ISA, $VERSION);
      #@ISA = qw( );

      sub new
      {
      my ($class,%args) = @_;
      my $self={};
      use Data::Dumper;
      use diagnostics;
      print "in simple->new!!!\n";
      bless $self,ref $class || $class ;
      while (my($key,$value) = each %args) { $self->set_attribute($key,$value); }
      print "Args passed to simple->new =",Dumper(\%args),"\n\n";
      $self->set_attribute('error',0);
      print "------new DUMPER------\n\n",Dumper(\$self),"\n\n------END------\n\n";
      print "done with new!\n" ;
      return $self;
      }

      sub DESTROY
      {
      my $self=shift;
      use Data::Dumper;
      use Carp;
      print "\n\n\nWARNING\nWARNING\nWARNING\n\nObject has been destroyed!!!!\n";
      print "------DESTROY DUMPER------\n\n",Dumper(\$self),"\n\n------END------\n\n";

      confess "end of DESTROY ...\n";
      }

      sub burp
      {
      my $self=shift;
      print "------burp DUMPER------\n\n",Dumper(\$self),"\n\n------END DUMPER------\n\n";
      return `date` ;
      }

      #
      # # Mutator method for an arbitrary attribute
      #
      sub set_attribute
      {
      my ($self,$key,$value) = @_;
      print "setting $key => $value \n";
      return $self->{$key}=$value;
      }

      #
      # # Accessor method for an arbitrary attribute,
      #
      sub get_attribute
      {
      my ($self,$key) = @_;
      my $value=undef;
      $self->set_attribute('error',0);
      if (exists($self->{$key}))
      {
      $value=$self->{$key} ;
      }
      else
      {
      $self->set_attribute('error',"attribute ".$key." does not exist in object");
      }
      return $value;
      }
      1;


      ----------

      output from client 1 and server (not working correctly):

      (client 1)
      creating object



      calling new ...

      Unrecognized parameter 'attribute_1' in new() at ./client.pl line 20
      Unrecognized parameter 'attribute_2' in new() at ./client.pl line 20


      calling burp ...

      burp date =Thu Mar 14 15:04:15 EST 2002

      (server)
      19 >./server.pl
      Waiting ......

      ------burp DUMPER------

      $VAR1 = \'simple';


      ------END DUMPER------

      -----------

      output from client 2 and server (working properly)

      (client2)
      creating object

      Use of inherited AUTOLOAD for non-method main::new() is deprecated at ./client2.pl line 21.
      rc=$VAR1 = \bless( {
      'error' => '0',
      'attribute_1' => '54321',
      'attribute_2' => '12321'
      }, 'simple' );



      calling burp ...

      burp date =Thu Mar 14 15:06:48 EST 2002

      (server)
      Waiting ......

      in simple->new!!!
      setting attribute_1 => 54321
      setting attribute_2 => 12321
      Args passed to simple->new =$VAR1 = {
      'attribute_1' => '54321',
      'attribute_2' => '12321'
      };


      setting error => 0
      ------new DUMPER------

      $VAR1 = \bless( {
      'error' => 0,
      'attribute_1' => '54321',
      'attribute_2' => '12321'
      }, 'simple' );


      ------END------

      done with new!
      ------burp DUMPER------

      $VAR1 = \bless( {
      'error' => '0',
      'attribute_1' => '54321',
      'attribute_2' => '12321'
      }, 'simple' );


      ------END DUMPER------




      WARNING
      WARNING
      WARNING

      Object has been destroyed!!!!
      ------DESTROY DUMPER------

      $VAR1 = \bless( {
      'error' => 0,
      'attribute_1' => '54321',
      'attribute_2' => '12321'
      }, 'simple' );


      ------END------

      (in cleanup) end of DESTROY ...
      simple::DESTROY('simple=HASH(0x85bddd0)') called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 1201
      eval {...} called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 1201
      SOAP::Serializer::envelope('SOAP::Serializer=HASH(0x84a67a4)', 'response', 'burpResponse', 'Thu Mar 14 15:06:48 EST 2002^J', 'SOAP::Header=HASH(0x859bd58)') called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2186
      eval {...} called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2127
      SOAP::Server::handle('SOAP::Transport::HTTP::Daemon=HASH(0x8493934)', '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:S...') called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Transport/HTTP.pm line 258
      SOAP::Transport::HTTP::Server::handle('SOAP::Transport::HTTP::Daemon=HASH(0x8493934)') called at /usr/local/lib/perl5/site_perl/5.6.1/SOAP/Transport/HTTP.pm line 385
      SOAP::Transport::HTTP::Daemon::handle('SOAP::Transport::HTTP::Daemon=HASH(0x8493934)') called at ./server.pl line 16


      Joe
    • Duncan Cameron
      ... .. snipped ... Joe I think that you re just misunderstanding the syntax of the O-O approach, see the SOAP::Lite docs under implementation of OO interface
      Message 2 of 2 , Mar 14 1:44 PM
        On 2002-03-14 Joe Landman wrote:
        >Ok, got this one down to a really simple test code, with 1 server code
        >and 2 clients. Client 1 uses the "normal" method of doing things
        >(normal for me, been using them for ~6 months). Client 2 uses
        >autodispatch.
        >

        .. snipped ...
        Joe

        I think that you're just misunderstanding the syntax of the O-O approach,
        see the SOAP::Lite docs under 'implementation of OO interface'
        where it explains the syntax. In your case something like

        my $obj = $soap->call(
        new => ('attribute_1'=>54321,'attribute_2'=>12321)
        )
        ->result;

        my $date=$soap->call(burp => $obj)->result;
        print "burp date =",$date,"\n";

        seems to work.

        Duncan Cameron
      Your message has been successfully submitted and would be delivered to recipients shortly.