automating netscaler with soap


I recently had to script some citrix netscaler stuff (around using the running config to create graph trees in cacti and collectd with ecostats front end)

to use the soap interface you have to make a soap request to login, then reuse the returned cookie to authenticate the other requests like this.

I use this wget to login

wget   -O- --cookies=on --keep-session-cookies  --save-cookies cookies.txt  --post-file=login.xml --header="Content-Type: application/soap+xml"  http://yourNSip/soap  

and this to get the details of vservers etc.

  wget  -O- --load-cookies cookies.txt  --post-file=getlbserver.xml --header="Content-Type: application/soap+xml"  http://yourNSip/soap  

where the post-files contain the soap requests

you can pipe into xmllint to tidy up the output if you want

 | xmllint --format --encode utf-8 –

cat login.xml

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:NSConfig" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:header>
   <soapenv:body>
      <urn:login soapenv:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
         <username xsi:type="xsd:string">username</username>
         <password xsi:type="xsd:string">thisisnotmypassword</password>
      </urn:login>
   </soapenv:body>
</soapenv:header></soapenv:envelope>

cat getlbserver.xml

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:NSConfig" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:header>
   <soapenv:body>
      <urn:getlbvserver soapenv:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
      </urn:getlbvserver>
   </soapenv:body>
</soapenv:header></soapenv:envelope>

reference data  http://support.citrix.com/article/CTX117503
and http://support.citrix.com/proddocs/topic/netscaler-api-map-93/ns-api-query-config-con.html

Comments

Popular posts from this blog

Baileys liquor Chocolate Chip and Cream desert

nginx decode base64 url for use with imgproxy

using t1n1wall, opnsense or pfsense on Google Compute Engine GCE