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

Example please - server/client with arrays

Expand Messages
  • Andreas
    I am trying to implement a simple SOAP client/server and stumble on parameter passing - in my case how do I read an array. I am using Apache2::Soap via
    Message 1 of 1 , Dec 14, 2005
    View Source
    • 0 Attachment
      I am trying to implement a simple SOAP client/server and stumble on
      parameter passing - in my case how do I read an array.

      I am using Apache2::Soap via mod_perl. Basic no-parameter calling
      works fine. Below is the source I wrote.




      --------- httpd.conf ---------

      <Location /soap>
      SetHandler perl-script
      PerlResponseHandler Apache2::SOAP
      PerlSetVar dispatch_to "/soap"
      PerlSetVar options "compress_threshold => 10000"
      </Location>


      --------- /soap/Calculator.pl ---------

      package Calculator;

      sub version {
      return "v1.0";
      }

      sub add {
      my @x = shift;
      my $y = 0;
      while(@x) {
      $y = $y + shift(@x);
      }
      return $y;
      }

      1;

      -------- testsoap.pl ---------
      use SOAP::Lite;

      my $soap = SOAP::Lite
      -> uri('/Calculator')
      -> proxy('http://localhost/soap')
      -> on_fault(sub { my($soap, $res) = @_;
      die ref $res ? $res->faultdetail : $soap->transport->status, "\n";
      });

      my $result = $soap -> version();
      print $result->result;
      print "\n";

      my $result = $soap -> add(3,4);
      print $result->result;
      print "\n";

      ------- perl testsoap.pl --------

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