Module: VBox::WebService
- Defined in:
- lib/virtualbox/connection.rb
Class Method Summary collapse
- .connect(args = {}) ⇒ Object
- .debug ⇒ Object
- .debug=(debug) ⇒ Object
- .savon_debug ⇒ Object
- .savon_debug=(savon_debug) ⇒ Object
- .send_request(soap_method, soap_message) ⇒ Object
Class Method Details
.connect(args = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/virtualbox/connection.rb', line 7 def connect(args={}) host = args[:host] || '127.0.0.1' port = args[:port] || '18083' debug = args[:debug] || false savon_debug = args[:savon_debug] || false endpoint = "http://#{host}:#{port}" wsdl = endpoint + '/?wsdl' @conn = Savon.client(:wsdl => wsdl, :endpoint => endpoint, :log => savon_debug, :pretty_print_xml => savon_debug) if @conn.operations.include?(:i_websession_manager_logon) @debug = debug @savon_debug = savon_debug true else raise "Could not connect to VirtualBox SOAP Web Service at #{endpoint} (No VirtualBox SOAP service found)" end rescue Errno::ECONNREFUSED raise "Could not connect to VirtualBox SOAP Web Service at #{endpoint} (Connection refused)" end |
.debug ⇒ Object
32 33 34 |
# File 'lib/virtualbox/connection.rb', line 32 def debug @debug end |
.debug=(debug) ⇒ Object
36 37 38 |
# File 'lib/virtualbox/connection.rb', line 36 def debug=(debug) @debug = debug end |
.savon_debug ⇒ Object
40 41 42 |
# File 'lib/virtualbox/connection.rb', line 40 def savon_debug @debug end |
.savon_debug=(savon_debug) ⇒ Object
44 45 46 47 48 |
# File 'lib/virtualbox/connection.rb', line 44 def savon_debug=(savon_debug) @savon_debug = savon_debug @conn.globals[:log] = savon_debug @conn.globals[:pretty_print_xml] = savon_debug end |
.send_request(soap_method, soap_message) ⇒ Object
26 27 28 29 30 |
# File 'lib/virtualbox/connection.rb', line 26 def send_request(soap_method, ) puts "DEBUG --- REQUEST: #{soap_method}, #{}" if @debug response = @conn.call(soap_method, :message => ) parse_response(response) end |