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

soap::lite v6.0 + service dispatch example at SOAPLITE.COM

Expand Messages
  • cnguyenvn
    hi, I alter the hibyemix.cgi: service dispatch example from the userguide section at soaplite.com to include the Temperatures service example to work in
    Message 1 of 1 , Jun 3, 2005
    • 0 Attachment
      hi,

      I alter the hibyemix.cgi: service dispatch example from
      the userguide section at soaplite.com to include the
      Temperatures service example to work in mod_perl
      environment.

      The Temperatures example temper.cgi + tempobj.pl works
      and return result as expected. but when i tried with
      the code below, the client code's return cycles between
      3 different output: 37, -17, and <no output> and other time just -17

      i've turned on the +trace option and i notice
      differences in the xml response where the call to NEW
      method and xml request where the call to AS_CELCIUS
      method for each case: where output is -17- call to NEW
      method failed, and in case no output - call to
      AS_CELCIUS method is failed.

      for simple calls: f2c() and c2f() where the parameter is a simple
      scalar, the same code below works fine. but the call AS_CELSIUS
      appeared to be failed with the argument is an object.

      as i've mentioned, when i tried the example temper.cgi + tempobj.pl,
      the example works fine. the problem occured when I try with 'service
      dispatch' style - ->dispatch_to ('/path', modules list)

      Please let me know where thing went wrong. thanks.
      ---------------------

      Here are the code i used:

      ########################
      # APACHE.PM
      ########################

      package Shared::Apache;

      use SOAP::Transport::HTTP;

      my $server = SOAP::Transport::HTTP::Apache
      -> dispatch_to('/home/soaplite/modules');

      sub handler { $server->handler(@_) }

      1;

      ########################
      # TEMPERATURES.PM
      ########################

      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 {
      return 5/9*(shift->{_temperature}-32);
      }

      1;

      ########################
      # TEMPOBJ.PL
      ########################

      #!/usr/local/perl5.8/bin/perl

      my $soap = SOAP::Lite
      -> uri('Temperatures')
      -> proxy('http://10.3.2.87/soap');

      my $temperatures = $soap
      -> call(new => 100) # accept Fahrenheits
      -> result;

      print $soap
      -> as_celsius($temperatures)
      -> result;
    Your message has been successfully submitted and would be delivered to recipients shortly.