Class: SOAP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl-reader/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Response

:nodoc:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wsdl-reader/response.rb', line 10

def initialize(request) #:nodoc:
  @request = request
  url = URI.parse(request[:uri])
  @soap_response = Net::HTTP.new(url.host, url.port).start { |http|
    http.post(url.request_uri, @request[:envelope], @request[:headers])
  }
  
  @to_xml = @soap_response.body
  @to_h = {}
  
  if @request[:wsdl].nil? or @request[:response].nil?
    require 'rubygems'
    require 'active_support'
    
    @to_h = Hash.from_xml(@soap_response.body)
  else
    processResponse() 
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object



30
31
32
# File 'lib/wsdl-reader/response.rb', line 30

def method_missing(id, *args)
  get(id.id2name)
end

Instance Attribute Details

#to_hObject (readonly)

Hash response



8
9
10
# File 'lib/wsdl-reader/response.rb', line 8

def to_h
  @to_h
end

#to_xmlObject (readonly)

XML response



6
7
8
# File 'lib/wsdl-reader/response.rb', line 6

def to_xml
  @to_xml
end

Instance Method Details

#[](name) ⇒ Object



34
35
36
# File 'lib/wsdl-reader/response.rb', line 34

def [](name)
  @to_h[name]
end

#errorObject

Return SOAP error



42
43
44
# File 'lib/wsdl-reader/response.rb', line 42

def error
  @soap_response.error!
end

#get(name) ⇒ Object



37
38
39
# File 'lib/wsdl-reader/response.rb', line 37

def get(name)
  @to_h[name]
end