Ruby and SOAP Revisited

An alternative method for using ZXTM's Control api with Ruby is to use the soap4r SOAP implementation. I have found this to be quite useful when writing scripts for testing recently. Soap4r can be found at,

http://dev.ctor.org/soap4r

Note: At the time of writing the use of soap4r depends on the 'httpclient' Ruby library, formerly known as 'http-access2'.

The first thing you have to do is obtain the published specification for ZXTM's API. You can download this from the product's admin interface, Diagnose > Technical Support, clicking "Control API WSDL Files". Extract this zip file to get the WSDL files we are looking for.

Soap4r comes with a tool 'wsdl2ruby.rb' which will take our WSDL files and produce Ruby files which we can import into our scripts. The documentation for this tool is very good but the invocation you will use will look something like this,

wsdl2ruby.rb --wsdl VirtualServer.wsdl --type client

You will receive the following files,

VirtualServerClient.rb
VirtualServerDriver.rb
VirtualServerMappingRegistry.rb

Once this is done you can include these in the programs or scripts you write. The important difference here, from our previous Ruby example, is that we no longer have to define every function that we intend to use and the arguments it expects. Doing this for any non-trivial script is onerous, so Zeus suggest using soap4r. Here is the analogous listing enabled virtual servers example using soap4r,

#!/usr/local/bin/ruby
require "VirtualServerDriver.rb"
require "VirtualServer.rb"
endpoint = "https://zxtm:9090/soap"
username = "admin"
pass = "somepass"
driver = VirtualServerPort.new(endpoint)
driver.options["protocol.http.ssl_config.verify_mode"] = OpenSSL::SSL::VERIFY_NONE
driver.options["protocol.http.basic_auth"] << [endpoint,username,pass]
vslist = driver.getVirtualServerNames
enabled = driver.getEnabled(vslist)
vslist.length.times do |i|
if enabled[i]
puts vslist[i]
end
end

I hope this helps all you Ruby folks, it certainly helped me.

Dec [Zeus Dev Team] 09 April 2009 Bookmark with del.icio.us Post this article to Digg Post this article to reddit Post this article to Facebook Tweet this article 1 comment  

Comments:

This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.

Comment from: Jonathan Lambert [Visitor] · http://www.workhabit.com/
Um, thanks. You couldn't have been more helpful.
Permalink 04 March 2010 @ 07:03
Leave a comment ...
Your email address will not be displayed.
Your URL will be displayed.
This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)

Recently...

Other Resources