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

Re: [soaplite] More fun with arrays

Expand Messages
  • Christopher Parker
    ... Can someone offer assistance because my poor Perl skills are really showing through here? I have a tiny SOAP::Lite client calling a method on a SOAP::Lite
    Message 1 of 3 , May 10, 2004
    View Source
    • 0 Attachment
      --- gdhgdh <gdh@...> wrote:
      Can someone offer assistance because my poor Perl skills are really
      showing through here? I have a tiny SOAP::Lite client calling a
      method on a SOAP::Lite service, and though I can see all the
      elements of the returned array in a Dumper output, I cannot see how
      to access it via the SOAP::Lite methods.

      The client:

      #!/usr/bin/perl

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

      $soap = SOAP::Lite
      -> uri('System')
      -> proxy('http://my.server.ip/');

      $soapcall = $soap->getCurrentIP();
      print Dumper($soapcall);
      @lansettings = $soapcall->result;
      print "Current LAN settings:\n\n";
      print " IP Address: $lansettings[0]\n";
      print " Subnet Mask: $lansettings[1]\n";
      print " Default Gateway: $lansettings[2]\n";

      Unfortunately, the @lansettings array only has one element.
      -----

      You're returning an array with your server. ``result'' only returns the first element of this
      array (a scalar). ``paramsout'' returns the rest of your output parameters, minus the first
      element (if any exist).

      To completely rebuild your array, you'll have to do something like this:

      @lansettings = ($soapcall->result, $soapcall->paramsout);

      -OR-

      @lansettings = $soapcall->paramsall;

      This is explained at http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm#SOAP::SOM

      I believe this was also explained in the book "Programming Web Services with Perl". If you don't
      have this book, I recommend it (written by Pavel Kulchenko and Randy J. Ray). It's been an
      invaluable resource to me thus far. Additionally, you may wish to check out "Programming Web
      Services with SOAP" (written by James Snell, Dough Tidwell, and Pavel Kulchenko). Both are
      available directly from O'Reilly's Web site:

      - http://www.oreilly.com/catalog/pwebserperl/
      - http://www.oreilly.com/catalog/progwebsoap/

      HTH

      --
      Parker
    • gdhgdh
      ... returns the first element of this ... parameters, minus the first ... Of course! Now it comes back to me :( I ve been writing exclusively
      Message 2 of 3 , May 13, 2004
      View Source
      • 0 Attachment
        > You're returning an array with your server. ``result'' only
        returns the first element of this
        > array (a scalar). ``paramsout'' returns the rest of your output
        parameters, minus the first
        > element (if any exist).

        <slaps forehead>

        Of course! Now it comes back to me :(

        I've been writing exclusively in PHP with NuSOAP for months, but
        have now had to write a little client in Perl - thanks so much for
        the refresher! :)

        I'm a little embarrassed I wasn't able to find this in the perldocs
        myself :/

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