Ruby

Ruby has standard class for XML-RPC called XMLRPC::Client – you can find the documentation at http://www.ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/classes/XMLRPC/Client.html.

  1. Load class XMLRPC::Client.

    require "xmlrpc/client"

  2. Define structs AuthInfo, ServerAddress and CreationParameters.

    AuthInfo = Struct.new( "AuthInfo", :login, :password )

    ServerAddress = Struct.new( "ServerAddress", :ips, :macs )

    CreationParameters = Struct.new( "CreationParameters", :hwid )

  3. Define server connection.

    server = XMLRPC::Client.new2( 'https://ka.parallels.com:7050/', nil, 900 )

  4. Perform call to server and store response in result variable. Start with a begin. The code starting from here should be put into an begin/end block to catch possible exceptions. The method requires the following parameters:

    begin

    puts 'Performing Call'

    result = server.call( "partner10.createKey",

    AuthInfo.new( "API_USER", "API_PASSWORD" ),

    ServerAddress.new( [ "192.168.62.80" ], [] ),

    'ka-client',

    'VIRTUOZZO_2X3X',

    ['2CPU_40VPS'],

    CreationParameters.new('2111.4355.5697.53D9.C5B3.766A.843A.1984' ),

    [ 'VIRTUOZZO_TOOLS_FOR_LINUX' ],

    CreationParameters.new( '2111.4355.5697.53D9.C5B3.766A.843A.1984' ))

  5. Print out result from response.

    puts "Contents:"

    result.each { | key, value | puts "#{key}: #{value}" }

  6. Catch exceptions and finish begin/end block with end.

    rescue XMLRPC::FaultException => e

    puts "Error:"

    puts e.faultCode

    puts e.faultString

    end