The following code uses Stingray's Control API to list all the running virtual servers on a cluster. The code is written in C#.
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 { Stingray.VirtualServer p = new Stingray.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 ) { Console.WriteLine( "{0}", names ); } } } catch ( Exception e ) { Console.WriteLine( "{0}", e ); } } }
Running the example
This code works with the .NET 1.1 SDK and with Mono (use the most recent Mono build available from http://www.mono-project.com/). Using .Net 1.1, compile and run this example as follows:
C:\> wsdl -o:VirtualServer.cs -ntingray 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 -ntingray VirtualServer.wsdl
$ mcs /out:listVS.exe /rystem.Web.Services VirtualServer.cs listVS.cs
$ ./listVS.exe
Main website
Mail servers
Test site
The WSDL interface specifications for the Stingray Control API are located in ZEUSHOME/zxtm/etc/wsdl/.
Note the use of the IcertificatePolicy derived class to override the default certificate checking method. This allows the application to accept the Stingray's Admin Server's self-signed certificate.