SOAP API Questions w/ Ruby & Savon as a SOAP client

Discussion in 'General' started by tanner.danzey, Jun 18, 2014.

  1. tanner.danzey

    tanner.danzey New Member

    Hello all, I am experiencing some difficulties with a project I am working on related to ISPConfig. I am using the Ruby SOAP client gem by the name of "Savon" and I am trying to achieve a level of interop between my ruby script and our ISPConfig server. Here is my code currently:

    Code:
    #!/usr/bin/env ruby
    require "savon"
    
    def get_client
      Savon.client( endpoint: "https://endpoint:8080/remote/index.php",
                    namespace: "https://endpoint:8080/remote/",
                    ssl_verify_mode: :none)
    end
    
    @client = get_client
    @sessionid = @client.call(:login, message: {username: "##########", password: "#############3"}).body[:login_response][:return]
    puts "Session ID: #{@sessionid}"
    @commands = @client.call("get_function_list", message: {sessionid: @sessionid}).body[:get_function_list_response][:return][:item]
    puts "Printing every ISPConfig API command!"
    @commands.each do |cmd|
      puts "\"#{cmd}\""
    end
    puts "Printing sites.."
    err_count = 1
    count = 1
    width = 5
    threshold = false
    while !threshold do
      domain = @client.call("sites_web_domain_get", message: {sessionid: @sessionid, domainid: count}).body[:sites_web_domain_get_response][:return]
      count = (count+1)
      if not domain == false and not domain.nil?#if(!(domain == false) && !(domain.nil?))
        domain_name = domain[:item][9][:value]
        domain_id = domain[:item][0][:value]
        err_count = 1
        puts "Domain: #{domain_id} DNS: #{domain_name}"
      else
        puts "Null at #{count}"
        err_count = (err_count + 1)
        if err_count > 5
          puts "Reached gap threshold."
          threshold = true
        end
      end
    end
    
    
    Everything works up until printing domains. Well, to be fair, it -does- work, but when run in our test environment it takes 10 seconds. I want to know how I can send a request that sends me an array or hash of ALL the sites with one request. I hear that with php you can use a "%" to specify a wildcard ID but I have tried many different formats of % in this request in all sorts of places and I cannot get the desired affect. Please advise!

    Much thanks,
    Tanner Danzey
    Northstar Technology Group
     

Share This Page