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

4371Re: [soaplite] Problem with constructor

Expand Messages
  • Bryce Harrington
    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
      >
      >
      >
      >
      >
      >
      >
    • Show all 3 messages in this topic