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

soap lite question

Expand Messages
  • hillmw2000
    At this page there is an article on use SOAP:Lite http://www.perl.com/lpt/a/2001/01/soap.html#writing%20a%20cgibased% 20server Towards the middle of the page
    Message 1 of 2 , Mar 23, 2004
    • 0 Attachment
      At this page there is an article on use SOAP:Lite

      http://www.perl.com/lpt/a/2001/01/soap.html#writing%20a%20cgibased%
      20server

      Towards the middle of the page there is an example about using:

      Objects access (it's 'Simple Object access protocol', isn't it?)

      Then some examples:

      (temper.cgi):
      #!perl -w
      use SOAP::Transport::HTTP;
      SOAP::Transport::HTTP::CGI
      -> dispatch_to('Temperatures')
      -> handle;
      package Temperatures;
      sub f2c {
      my ($class, $f) = @_;
      return 5/9*($f-32);
      }
      sub c2f {
      my ($class, $c) = @_;
      return 32+$c*9/5;
      }
      sub new {
      my $self = shift;
      my $class = ref($self) || $self;
      bless {_temperature => shift} => $class;
      }
      sub as_fahrenheit {
      return shift->{_temperature};
      }
      sub as_celsius {
      my $self = $shift;
      return $self->f2c( $self->{_temperature} );
      }


      Here is a client that accesses this class:

      (tempobj.pl):
      #!perl -w
      use SOAP::Lite;
      my $soap = SOAP::Lite
      -> uri('http://www.soaplite.com/Temperatures')
      -> proxy('http://services.soaplite.com/temper.cgi');
      my $temperatures = $soap
      -> call(new => 100) # accept Fahrenheit
      -> result;
      print $soap
      -> as_celsius($temperatures)
      -> result;

      I ram this example executing > perl tempobj.pl and I get nothing. Can
      someone explain why?

      Mike
    • Nayana Hettiarachchi
      sub as_celsius { my $self = $shift; f2c( $self- {_temperature} ); } if you did a debug trace you could have
      Message 2 of 2 , Mar 23, 2004
      • 0 Attachment

        sub as_celsius {
              my $self = $shift;
        ß should be shift not $shift
              return $self->f2c( $self->{_temperature} );
          }

         

        if you did a debug trace you could have noticed it

        to do debug, trace

         

        use SOAP::Lite +trace => 'debug';

         

        hope this helps

         

        cheers

         

        Nayana

         

         

        -----Original Message-----
        From: hillmw2000 [mailto:caroline@...]
        Sent:
        Tuesday, March 23, 2004 4:36 PM
        To: soaplite@yahoogroups.com
        Subject: [soaplite] soap lite question

         

        At this page there is an article on use SOAP:Lite

        http://www.perl.com/lpt/a/2001/01/soap.html#writing%20a%20cgibased%
        20server

        Towards the middle of the page there is an example about using:

        Objects access (it's 'Simple Object access protocol', isn't it?)

        Then some examples:

        (temper.cgi):
        #!perl -w
          use SOAP::Transport::HTTP;
          SOAP::Transport::HTTP::CGI
            -> dispatch_to('Temperatures')
            -> handle;
          package Temperatures;
          sub f2c {
              my ($class, $f) = @_;
              return 5/9*($f-32);
          }
          sub c2f {
              my ($class, $c) = @_;
              return 32+$c*9/5;
          }
          sub new {
              my $self = shift;
              my $class = ref($self) || $self;
              bless {_temperature => shift} => $class;
          }
          sub as_fahrenheit {
              return shift->{_temperature};
          }
          sub as_celsius {
              my $self = $shift;
              return $self->f2c( $self->{_temperature} );
          }


        Here is a client that accesses this class:

        (tempobj.pl):
        #!perl -w
          use SOAP::Lite;
          my $soap = SOAP::Lite
            -> uri('http://www.soaplite.com/Temperatures')
            -> proxy('http://services.soaplite.com/temper.cgi');
          my $temperatures = $soap
            -> call(new => 100) # accept Fahrenheit 
            -> result;
          print $soap
            -> as_celsius($temperatures)
            -> result;

        I ram this example executing > perl tempobj.pl and I get nothing. Can
        someone explain why?

        Mike



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