Example: Listing Running Virtual Servers

Perl with SOAP::Lite

#!/usr/bin/perl -w

 

use SOAP::Lite 0.60;

 

# This is the url of the Traffic Manager Admin UI

my $admin_server = 'https://username:password@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";

}

}

Run the example as follows:

$ ./listVS.pl

Main website

Mail servers

Test site

C Sharp or Mono

using System;

using System.Net;

using System.IO;

using System.Security.Cryptography.X509Certificates;

 

public class AllowSelfSignedCerts : IcertificatePolicy {

public bool CheckValidationResult(

ServicePoint sp, X509Certificate cert,

WebRequest request, int problem )

{

return true;

}

}

 

public class listVS {

 

public static void Main( string [] args )

{

System.Net.ServicePointManager.CertificatePolicy =

new AllowSelfSignedCerts();

 

string url= "https://host:9090/soap";

string username = "username";

string password = "password";

 

try {

ZXTM.VirtualServer p = new ZXTM.VirtualServer();

p.Url = url;

p.Credentials = new NetworkCredential( username, password );

 

string[] names = p.getVirtualServerNames();

bool[] enabled = p.getEnabled( names );

 

for ( int i = 0; i < names.Length; i++ ) {

if( enabled[i] ) {

Console.WriteLine( "{0}", names[i] );

}

}

} catch ( Exception e ) {

Console.WriteLine( "{0}", e );

}

}

}

This code works with the .NET 1.1 SDK and with Mono.

Using .Net 1.1, compile and run this example as follows:

C:\> wsdl -o:VirtualServer.cs -n:ZXTM VirtualServer.wsdl

C:\> csc /out:listVS.exe VirtualServer.cs listVS.cs

C:\> listVS.exe

Main website

Mail servers

Test site

With Mono, compile and run as follows:

$ wsdl -o:VirtualServer.cs -n:ZXTM VirtualServer.wsdl

$ msc /out:listVS.exe /r:System.Web.Services \

VirtualServer.cs listVS.cs

$ listVS.exe

Main website

Mail servers

Test site

Further Examples

For further examples using other programming languages, see the Pulse Secure Virtual Traffic Manager: Control API Guide.