vADC Docs

Tech Tip: Using the SOAP Control API with Perl

by on ‎02-25-2013 07:37 AM (962 Views)

The following code uses Stingray's Control API to list all the running virtual servers on a cluster. The code is written in Perl, using the SOAP::Lite module:


listVS.pl


#!/usr/bin/perl -w


use SOAP::Lite 0.60;



# This is the url of the Stingray admin server


my $admin_server = 'https://usernameSmiley Tongueassword@host:9090';



my $conn = SOAP::Lite


   -> uri('http://soap.zeus.com/zxtm/1.0/VirtualServer/')


   -> proxy("$admin_server/soap");



# Get a list of virtual servers


my $res = $conn->getVirtualServerNames();


my @names = @{$res->result};



# Establish which are enabled


$res = $conn->getEnabled( \@names );


my @enabled = @{$res->result};



# Print those which are enabled


for( my $i = 0; $i <= $#names; $i++ ) {


   if( $enabled[$i] ) {


      print "$names[$i]\n";


   }


}


Running the Example

$ ./listVS.pl

Main website

Mail servers

Test site

Notes

To run this example, you will need Perl, SOAP::Lite and IO:Smiley Frustratedocket:Smiley FrustratedSL. On Debian-based systems, you may install the packages libsoap-lite-perl and libio-socket-ssl-perl. On RedHat based systems, you'll need the perl-SOAP-Lite and perl-IO-Socket-SSL rpms.

Perl's SOAP::Lite module does not use the WSDL file to perform any type checking, so calling errors will be detected at runtime. The SSL layer is happy to accept self-signed certificates.

Read more