Class: WebMethods::Server
- Inherits:
-
Object
- Object
- WebMethods::Server
- Defined in:
- lib/web_methods/server.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(host, port, username, password) ⇒ Server
constructor
A new instance of Server.
- #invoke(package, service, params) ⇒ Object
Constructor Details
#initialize(host, port, username, password) ⇒ Server
Returns a new instance of Server.
9 10 11 12 |
# File 'lib/web_methods/server.rb', line 9 def initialize host, port, username, password @host, @port, @username, @password = host, port, username, password @logger = Log4r::Logger.new("WebMethods::Server") end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/web_methods/server.rb', line 7 def logger @logger end |
Instance Method Details
#invoke(package, service, params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/web_methods/server.rb', line 14 def invoke package, service, params @logger.debug "Connecting to #{@host}:#{@port}" res = Net::HTTP.start(@host, @port) do |http| url = "/invoke/#{package}/#{service}?#{params.map{|k,v|"#{k}=#{v}"}.join('&')}" @logger.debug "Sending request to #{url}" req = Net::HTTP::Get.new(url) req.basic_auth @username, @password response = http.request(req) @logger.debug "Received response: #{response}" body = response.body @logger.debug "Body was:\n#{body}" hash = HtmlParser.new(body).parse @logger.debug "Parsed to #{hash.inspect}" hash end end |