Class: SOAP::Response
- Inherits:
-
Object
- Object
- SOAP::Response
- Defined in:
- lib/wsdl-reader/response.rb
Instance Attribute Summary collapse
-
#to_h ⇒ Object
readonly
Hash response.
-
#to_xml ⇒ Object
readonly
XML response.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#error ⇒ Object
Return SOAP error.
- #get(name) ⇒ Object
-
#initialize(request) ⇒ Response
constructor
:nodoc:.
- #method_missing(id, *args) ⇒ Object
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_h ⇒ Object (readonly)
Hash response
8 9 10 |
# File 'lib/wsdl-reader/response.rb', line 8 def to_h @to_h end |
#to_xml ⇒ Object (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 |
#error ⇒ Object
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 |