Introduction |  Requirement |  Compiling samples |  Usage |  Samples |  Feature configuration samples
Introduction
The example code that accompanies this file uses GSOAP to communicate with Netscaler, using XML/SOAP. Here, we describe how to get it up and running.

The full NSConfig.wsdl file is very large - WSDL to C interface generation utility can take time to parse it. You can avoid this by creating a custom subset of the WSDL, containing just the methods used in these examples:
filterwsdl NSConfig.fullwsdl "add service" "set service*" "show service"
"bind lbmonitor*" "add lb vserver" "bind lb vserver*"
"show lb vserver" "rm service" "rm vserver"
"save nsconfig" > NSConfig.wsdl
Note that you need to modify NSConfig.wsdl file at the bottom, where it says location="http://NetScaler/soap/" to location="http://10.100.50.25/soap/", where 10.100.50.25 is assumed to be your Netscaler's IP address.

The setConfig.c example uses the Netscaler API to:
  • log in to Netscaler
  • add a service
  • bind a monitor
  • add a vserver
  • bind a service to a vserver
  • save configuration
  • remove added vservers and services
  • log out
The getConfig.c example fetches information about all configured lb vservers,and prints selected information about each one.

The rmConfig.c example removes all of the configuration that was created by setConfig.cs.

The getStat.c example demonstrates usage of statistical api.

Additional documentation is available as inline comments in the C programs.
Requirement
  • C compiler
  • gsoap 2.7 and later
  • gmake (optional on Windows)
Compiling samples
1. Extract files from the archive. It contains, among other files -
  • gSOAP WSDL processor (wsdl2h)
  • gSOAP SOAP compiler (soapcpp2) and run-time (stdsoap2.c)
  • NetScaler WSDL generator (filterwsdl)
2. Customize the Makefile (or makesamp.bat on Windows), setting the variables at the top to match your environment.

3. Obtain the NetScaler WSDL file. The wsdl file for the API is located on the Netscaler device,at http://Netscaler/api/NSConfig.wsdl. The full NSConfig.wsdl file is very large - it will take up to five minutes or more to compile the generated C stubs. You can avoid this by creating a custom subset of the WSDL, containing just the methods used in these examples:

filterwsdl NSConfig.fullwsdl "add service" "set service*" "show service"
"bind lbmonitor*" "add lb vserver" "bind lb vserver*"
"show lb vserver" "rm service" "rm vserver"
"save nsconfig" > NSConfig.wsdl

NOTE: you must modify the NSConfig.wsdl file, in the <service> section at the bottom; change "Netscaler" to the IP address of your Netscaler in 'location="http://NetScaler/soap/"'.

4. Build the three samples. In the directory where you extracted these files, type "gmake [ENTER]" or on windows "makesamp [ENTER]". This will -
  • Create two files - NSConfig.h and NSConfig.c.
  • Create XML request/response files, and SOAP stubs.
  • Compile the example C clients.
Usage
The parameters to all of the examples are:

setConfig <protocol>://<NSIP> <username> <password>
getConfig <protocol>://<NSIP> <username> <password>
rmConfig <protocol>://<NSIP> <username> <password>
Samples
getConfig.c The getConfig example fetches information about all configured entities, and prints selected information about each one.
setConfig.c The setConfig example uses the Netscaler API to set and bind certain entities in the System.
rmConfig.c The rmConfig example removes all of the configuration that was created by setConfig.
getStat.c The getStat example demonstrates usage of statistical api.
Feature configuration samples
acl.c ACL configuration sample.
cmp.c Compression configuration sample.
csw.c Content Switching configuration sample.
lb.c Load Balancer configuration sample.
rba.c RBA configuration sample.
rewrite.c Rewrite configuration sample.
ssl.c SSL Base configuration sample.
ssl_crl.c SSL Client-Auth with CRL configuration sample.