Class: SOAP::Response
- Inherits:
-
Object
- Object
- SOAP::Response
- Defined in:
- lib/soap/lc/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:
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/soap/lc/response.rb', line 11 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
31 32 33 |
# File 'lib/soap/lc/response.rb', line 31 def method_missing( id, *args ) get( id.id2name ) end |
Instance Attribute Details
#to_h ⇒ Object (readonly)
Hash response
9 10 11 |
# File 'lib/soap/lc/response.rb', line 9 def to_h @to_h end |
#to_xml ⇒ Object (readonly)
XML response
7 8 9 |
# File 'lib/soap/lc/response.rb', line 7 def to_xml @to_xml end |
Instance Method Details
#[](name) ⇒ Object
35 36 37 |
# File 'lib/soap/lc/response.rb', line 35 def [](name) @to_h[name] end |
#error ⇒ Object
Return SOAP error
43 44 45 |
# File 'lib/soap/lc/response.rb', line 43 def error @soap_response.error! end |
#get(name) ⇒ Object
38 39 40 |
# File 'lib/soap/lc/response.rb', line 38 def get( name ) @to_h[name] end |