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

Re: SOAP::Lite, WSDL and execution loops/delays

Expand Messages
  • Scott Francis
    ... Following up with code inline, in hopes of soliciting some comments: #!/usr/bin/perl -w # # use Perl and NetScaler s SOAP API service - primarily useful #
    Message 1 of 3 , Jun 23, 2006
    • 0 Attachment
      On 6/19/06, Scott Francis <darkuncle@...> wrote:
      > So I'm using SOAP::Lite to build a Perl interface to a NetScaler load
      > balancer (end goal is to have servers added and removed from a pool in
      > an automated fashion). The interface is via WSDL[0], and my code[1]
      > successfully connects (uses HTTP::Cookies for authentication),
      > executes a command and parses the response.

      Following up with code inline, in hopes of soliciting some comments:

      #!/usr/bin/perl -w

      #
      # use Perl and NetScaler's SOAP API service - primarily useful
      # for scripted activity, since NS already has a java-based GUI and runs sshd
      #

      use strict;
      use SOAP::Lite;
      use Data::Dumper;

      # uncomment the following to dump complete SOAP::Lite output
      # this is EXCEEDINGLY verbose - you have been warned!
      #SOAP::Lite->import(+trace => [ "all", "-objects" ]);

      # NetScaler SOAP API uses cookie-based authentication
      use HTTP::Cookies;

      # non-HTTP debugging - if enabled, debug("foo") prints "foo\n" to stderr
      # set to 1 to enable, 0 to disable
      use constant DEBUG => 1 ;
      sub debug { print STDERR "@_\n" if DEBUG; }

      # take CLI argument for operation, or default to getnsversion()
      my $operation = shift @ARGV || "getnsversion";
      my @arguments = @ARGV;

      debug("operation: $operation");
      debug("arguments: @arguments");

      # login credentials
      my $username = 'user';
      my $password = 'pass';

      debug("username: $username");
      debug("password: $password");

      # location of WSDL file and SOAP proxy
      my $ns_wsdl = 'file:./NSConfig.wsdl';
      my $ns_proxy = 'http://10.10.10.254/soap/';

      debug("ns_wsdl: $ns_wsdl");
      debug("ns_proxy: $ns_proxy");

      # instantiate SOAP object - this is where our 563K create/destroy loop begins
      ####
      # BEGIN EXECUTION DELAY
      ####
      my $soapobj = SOAP::Lite
      ->service("$ns_wsdl")
      ->proxy("$ns_proxy",
      cookie_jar => HTTP::Cookies->new(ignore_discard => 1),
      timeout => 5)
      ;
      ####
      # END EXECUTION DELAY
      ####

      # print perl object we'll be sending to the proxy
      DEBUG && print "dumping request - \$soapobj perl object:\n", Dumper($soapobj);

      # login
      my $login = $soapobj->login("$username", "$password") or die "login
      failure: $@\n";

      # use SOAP object to create $soapres object that actually performs our
      $operation
      my $soapres = $soapobj->$operation(@arguments) or die "$operation
      failure: $@\n";

      # Data::Dumper++ - we can see the output that's returned as Perl sees it!
      DEBUG && print "dumping response - \$soapres perl object:\n", Dumper($soapres);

      # the name and type of object returned varies with each $operation
      # our code is not yet smart enough to automagically PTRT (print the right thing)

      if ($operation eq "getnsversion") {
      # getnsversion()->version returns scalar
      print "version string: ", $soapres->{List}->[0]->{version}, "\n";
      } elsif ($operation eq "getlbvserver") {
      # getlbvserver()->serviceName returns array
      local $" = "\n ";
      print "getlbvserver list:\n @{$soapres->{List}->[0]->{serviceName}}\n";
      }

      DEBUG && print "return code: ", $soapres->{rc}, "\n";
      DEBUG && print "message: ", $soapres->{message}, "\n";

      unless ($soapres->{rc} == 0) {
      print "an error occurred: ", $soapres->{message}, "\n";
      }


      thanks for any comments, folks.
      --
      darkuncle@{gmail.com,darkuncle.net} || 0x5537F527
      encrypted email to the latter address please
      http://darkuncle.net/pubkey.asc for public key
    • Christopher Heschong
      ... ... Just as an FYI, I have reproduced this myself. Although I don t have any suggestions to help, I thought it might help to note that the problem seems
      Message 2 of 3 , Jun 27, 2006
      • 0 Attachment
        --- In soaplite@yahoogroups.com, "Scott Francis" <darkuncle@...> wrote:

        ...

        > When I turned on
        > SOAP::Lite->import(+trace => "all");
        > and directed output to a temp file[2], I found that the code was doing
        > a little over 560,000 apparently empty
        > SOAP::Data::new()/SOAP::Data::DESTROY() loops during the instantiation
        > of the SOAP object.

        ...


        Just as an FYI, I have reproduced this myself. Although I don't have any suggestions to
        help, I thought it might help to note that the problem seems to lie within generating the
        definitions from the service :

        use SOAP::Lite; my $soapobj = SOAP::Lite->service( "file:./NSConfig.wsdl" ); # Hangs


        Anyone have any ideas?
      Your message has been successfully submitted and would be delivered to recipients shortly.