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

Caching WSDL files...

Expand Messages
  • ntang_work
    I ve written a quick test soap script and it seems to work but parsing the WSDL takes forever (and by that I mean over 1 minute per run, the WSDL file is 14000
    Message 1 of 3 , Oct 24, 2007
    • 0 Attachment
      I've written a quick test soap script and it seems to work but parsing
      the WSDL takes forever (and by that I mean over 1 minute per run, the
      WSDL file is 14000 lines long).

      So I tried using the cache_dir option, and it does write out a cache
      file, which appears to just be a perl module. But it still takes just
      as long.

      So *then* I tried calling the perl module directly. Now it's fast,
      but it doesn't seem to keep state, so after I log in, it forgets that
      I'm logged in when I try to run commands.


      Here's an abbreviated version of the first script, that's slow but works:

      #!/usr/bin/perl -w

      use SOAP::Lite;
      use HTTP::Cookies;
      use Getopt::Long;

      # Optionally, set default inline username and password here - I
      recommend a read-only account!
      my $username = '';
      my $password = '';

      GetOptions (
      "username=s" => \$username,
      "password=s" => \$password,
      "server=s" => \@servers,
      "vserver=s" => \@vservers,
      "service=s" => \@services,
      );

      my $cookies = HTTP::Cookies->new(ignore_discard => 1, hide_cookie2 =>
      1, file => '/tmp/nscookies');

      print "\nParsing the Netscaler wsdl... (this can take a while...)\n";
      my $soap = SOAP::Lite
      -> cache_dir("/tmp")
      -> service('file:./NSConfig.wsdl.orig')
      -> proxy('http://10.50.0.1/soap/', cookie_jar=>$cookies)
      ;

      $cookies->save;

      print "Ok, done! Logging in.\n";
      my $login = $soap->login($username,$password);
      ref_output($login);
      print "\n";

      foreach my $service (@services) {
      print "SERVICE $service\n";
      my $result = $soap->getservice($service);
      ref_output($result);
      print "\n";
      }

      sub ref_output {
      my $ref = shift @_;
      while ( my ($key,$value) = each %$ref ) {
      if ( $key =~ /(List|soThreshold|PolicyName|monitorName)/ ) {
      foreach (@$value) {
      print " $key:\n";
      ref_output($_);
      }
      }
      else {
      print " $key: $value\n";
      }
      }
      }


      That works fine.

      Here's what I tried to do w/ the resulting cached perl module:

      #!/usr/bin/perl -w

      use SOAP::Lite;
      use HTTP::Cookies;
      use Getopt::Long;
      use lib qw(/tmp);
      use NSConfigService;

      # Optionally, set default inline username and password here - I
      recommend a read-only account!
      my $username = '';
      my $password = '';

      my $cookies = HTTP::Cookies->new(ignore_discard => 1, hide_cookie2 =>
      1, file => '/tmp/nscookies');

      my $soap = NSConfigService;

      print "Ok, done! Logging in.\n";
      my $login = $soap->login($username,$password);
      # my $login = NSConfigService->login($username,$password);
      ref_output($login);
      print "\n";

      foreach my $service (@services) {
      print "SERVICE $service\n";
      # my $result = NSConfigService->getservice($service);
      my $result = $soap->getservice($service);
      ref_output($result);
      print "\n";
      }

      sub ref_output {
      my $ref = shift @_;
      while ( my ($key,$value) = each %$ref ) {
      if ( $key =~ /(List|soThreshold|PolicyName|monitorName)/ ) {
      foreach (@$value) {
      print " $key:\n";
      ref_output($_);
      }
      }
      else {
      print " $key: $value\n";
      }
      }
      }



      The output from the second version reads as follows:

      [root@cc17-10 test-netscaler]# ./nsshow2.pl --service cc80-10-http

      Ok, done! Logging in.
      rc: 0
      message: Done

      SERVICE cc80-10-http
      rc: 1027
      message: Not logged in or connection timed out

      [root@cc17-10 test-netscaler]#



      Any ideas as to what I can do to either a.) get the first version
      working quickly, or b.) get the second version to work?


      Thanks!
      Nicholas
    • Nicholas Tang
      ARGH. I apologize. Figures - after wrestling with it for 2 hours, I figure it out 10 minutes after emailing the list. my $cookies =
      Message 2 of 3 , Oct 24, 2007
      • 0 Attachment
        ARGH. I apologize. Figures - after wrestling with it for 2 hours, I
        figure it out 10 minutes after emailing the list.


        my $cookies = HTTP::Cookies->new(ignore_discard => 1, hide_cookie2 =>
        1, file => '/tmp/nscookies', autosave => 1);

        my $soap = NSConfigService
        -> proxy('http://10.50.0.1/soap/', cookie_jar=>$cookies)
        ;


        I didn't realize you could pass all of the standard SOAP::LITE
        options. Once I did that, and used the cookie_jar, it worked.
        Whoops.

        Apologies, but hopefully it'll help the next person that gets confused. :)

        Nicholas
      • Nicholas Tang
        Here s what I ended up doing, which is working beautifully and is a lot more clever ... #!/usr/bin/perl -w use HTTP::Cookies; use Getopt::Long; use lib
        Message 3 of 3 , Oct 31, 2007
        • 0 Attachment
          Here's what I ended up doing, which is working beautifully and is a
          lot more "clever"...

          #!/usr/bin/perl -w

          use HTTP::Cookies;
          use Getopt::Long;
          use lib qw(/usr/local/bin);
          use SOAP::Lite;

          my $cookies = HTTP::Cookies->new(ignore_discard => 1, hide_cookie2 =>
          1, autosave => 1);

          # Optionally, set default inline username and password here - I
          recommend a read-only account!
          my $username = '';
          my $password = '';
          my $debug = 0;
          my $soap;

          eval {
          require NSConfigService;
          };
          if ($@) {
          print "\nNo cache file found! Parsing the Netscaler wsdl... (this
          can take a while...)\n";
          $soap = SOAP::Lite
          -> cache_dir("/usr/local/bin")
          -> service('file:./NSConfig.wsdl')
          -> proxy('http://10.50.0.1/soap/', cookie_jar=>$cookies)
          ;
          }
          else {
          import NSConfigService;
          $soap = NSConfigService
          -> proxy('http://10.50.0.1/soap/', cookie_jar=>$cookies)
          ;
          }

          GetOptions (
          "username=s" => \$username,
          "password=s" => \$password,
          );


          etc. etc. etc.

          On 10/24/07, Nicholas Tang <nicholastang@...> wrote:
          > ARGH. I apologize. Figures - after wrestling with it for 2 hours, I
          > figure it out 10 minutes after emailing the list.
          >
          >
          > my $cookies = HTTP::Cookies->new(ignore_discard => 1, hide_cookie2 =>
          > 1, file => '/tmp/nscookies', autosave => 1);
          >
          > my $soap = NSConfigService
          > -> proxy('http://10.50.0.1/soap/', cookie_jar=>$cookies)
          > ;
          >
          >
          > I didn't realize you could pass all of the standard SOAP::LITE
          > options. Once I did that, and used the cookie_jar, it worked.
          > Whoops.
          >
          > Apologies, but hopefully it'll help the next person that gets confused. :)
          >
          > Nicholas
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.