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

Problem with constructor

Expand Messages
  • ojnesad
    Hi to all !! Im new in the list and new to soaplite. Im trying to expose a module as a web service and im having problems to make execute the code in the
    Message 1 of 3 , Jan 27, 2005
    • 0 Attachment
      Hi to all !!

      Im new in the list and new to soaplite. Im trying to expose a module
      as a web service and im having problems to make execute the code in
      the constructor each time that I create an object.

      The code of the module is:
      --
      package datos::pys::Sector;
      sub getNombre {
      my $self = shift;
      return $self->{NOMBRE};
      }
      sub setNombre {
      my $self = shift;
      if (@_) { $self->{NOMBRE} = shift; return; }
      }
      sub new {
      my $class = shift;
      my $self = {};
      $self->{NOMBRE} = "Nombre1";
      bless($self,$class);
      return $self;
      }
      return 1;
      --

      When I use a "stand-alone" client of the class I can see "Nombre1" the
      first time I call getNombre, but when I use a SOAP::Lite client it
      seems like the code in new never execute.

      Im using the following client:
      --
      #!/usr/bin/perl -w
      use strict;
      use SOAP::Lite;

      my $soap = SOAP::Lite
      -> uri('http://localhost:8070/datos/pys/Sector')
      -> proxy('http://localhost:8070/')i;

      my $sector = $soap->call(new => '')->result;
      my $res = $soap->getNombre()->result;
      print "initial result: ". $res."\n";

      $soap->setNombre("Juan")->result;
      $res = $soap->getNombre()->result;
      print "result: ". $res."\n";

      $soap->setNombre("Diego")->result;
      $res = $soap->getNombre()->result;
      print "result: ". $res."\n";
      --

      Thanks for your help.

      Bye.
    • Duncan Cameron
      ... You probably need to pass the sector object which is returned by the new method, on each of the subsequent calls, e.g. my $sector = $soap- call(new =
      Message 2 of 3 , Jan 27, 2005
      • 0 Attachment
        --- ojnesad <dasenjo@...> wrote:
        >
        >
        > Hi to all !!
        >
        > Im new in the list and new to soaplite. Im trying to expose a module
        > as a web service and im having problems to make execute the code in
        > the constructor each time that I create an object.
        >
        > The code of the module is:
        > --
        > package datos::pys::Sector;
        > sub getNombre {
        > my $self = shift;
        > return $self->{NOMBRE};
        > }
        > sub setNombre {
        > my $self = shift;
        > if (@_) { $self->{NOMBRE} = shift; return; }
        > }
        > sub new {
        > my $class = shift;
        > my $self = {};
        > $self->{NOMBRE} = "Nombre1";
        > bless($self,$class);
        > return $self;
        > }
        > return 1;
        > --
        >
        > When I use a "stand-alone" client of the class I can see "Nombre1"
        > the
        > first time I call getNombre, but when I use a SOAP::Lite client it
        > seems like the code in new never execute.
        >
        > Im using the following client:
        > --
        > #!/usr/bin/perl -w
        > use strict;
        > use SOAP::Lite;
        >
        > my $soap = SOAP::Lite
        > -> uri('http://localhost:8070/datos/pys/Sector')
        > -> proxy('http://localhost:8070/')i;
        >
        > my $sector = $soap->call(new => '')->result;
        > my $res = $soap->getNombre()->result;
        > print "initial result: ". $res."\n";
        >
        > $soap->setNombre("Juan")->result;
        > $res = $soap->getNombre()->result;
        > print "result: ". $res."\n";
        >
        > $soap->setNombre("Diego")->result;
        > $res = $soap->getNombre()->result;
        > print "result: ". $res."\n";

        You probably need to pass the 'sector' object which is returned by the
        'new' method, on each of the subsequent calls, e.g.

        my $sector = $soap->call(new => '')->result;
        my $res = $soap->getNombre($sector)->result;

        Duncan






        ___________________________________________________________
        ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
      • Bryce Harrington
        ... Try getting the fault out of the above call. Often SOAP will tell you what s going wrong internally. I.e. my $response = $soap- getNombre(); if
        Message 3 of 3 , Jan 27, 2005
        • 0 Attachment
          On Thu, 27 Jan 2005, ojnesad wrote:

          >
          >
          > Hi to all !!
          >
          > Im new in the list and new to soaplite. Im trying to expose a module
          > as a web service and im having problems to make execute the code in
          > the constructor each time that I create an object.
          >
          > The code of the module is:
          > --
          > package datos::pys::Sector;
          > sub getNombre {
          > my $self = shift;
          > return $self->{NOMBRE};
          > }
          > sub setNombre {
          > my $self = shift;
          > if (@_) { $self->{NOMBRE} = shift; return; }
          > }
          > sub new {
          > my $class = shift;
          > my $self = {};
          > $self->{NOMBRE} = "Nombre1";
          > bless($self,$class);
          > return $self;
          > }
          > return 1;
          > --
          >
          > When I use a "stand-alone" client of the class I can see "Nombre1" the
          > first time I call getNombre, but when I use a SOAP::Lite client it
          > seems like the code in new never execute.
          >
          > Im using the following client:
          > --
          > #!/usr/bin/perl -w
          > use strict;
          > use SOAP::Lite;
          >
          > my $soap = SOAP::Lite
          > -> uri('http://localhost:8070/datos/pys/Sector')
          > -> proxy('http://localhost:8070/')i;
          >
          > my $sector = $soap->call(new => '')->result;
          > my $res = $soap->getNombre()->result;

          Try getting the fault out of the above call. Often SOAP will tell you
          what's going wrong internally. I.e.

          my $response = $soap->getNombre();
          if ($response->fault) {
          print join ', ',
          $response->faultcode,
          $response->faultstring;
          exit -1;
          }
          my $res = $response->result;

          > print "initial result: ". $res."\n";
          >
          > $soap->setNombre("Juan")->result;
          > $res = $soap->getNombre()->result;
          > print "result: ". $res."\n";
          >
          > $soap->setNombre("Diego")->result;
          > $res = $soap->getNombre()->result;
          > print "result: ". $res."\n";
          > --
          >
          > Thanks for your help.
          >
          > Bye.
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.