Class: Savon::Response
Overview
Savon::Response
Represents the HTTP and SOAP response.
Constant Summary collapse
- MaxNonErrorResponseCode =
The maximum HTTP response code considered to be OK.
299
- @@raise_errors =
The global setting of whether to raise errors.
true
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the HTTP response object.
-
#http_error ⇒ Object
readonly
Returns the HTTP error message.
-
#soap_fault ⇒ Object
readonly
Returns the SOAP fault message.
Class Method Summary collapse
-
.raise_errors=(raise_errors) ⇒ Object
Sets the global setting of whether to raise errors.
-
.raise_errors? ⇒ Boolean
Returns the global setting of whether to raise errors.
Instance Method Summary collapse
-
#http_error? ⇒ Boolean
Returns whether there was an HTTP error.
-
#initialize(http) ⇒ Response
constructor
Expects a Net::HTTPResponse and handles errors.
-
#soap_fault? ⇒ Boolean
Returns whether there was a SOAP fault.
-
#to_hash ⇒ Object
Returns the SOAP response body as a Hash.
-
#to_xml ⇒ Object
(also: #to_s)
Returns the SOAP response XML.
Constructor Details
#initialize(http) ⇒ Response
Expects a Net::HTTPResponse and handles errors.
25 26 27 28 29 30 |
# File 'lib/savon/response.rb', line 25 def initialize(http) @http = http handle_soap_fault handle_http_error end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the HTTP response object.
59 60 61 |
# File 'lib/savon/response.rb', line 59 def http @http end |
#http_error ⇒ Object (readonly)
Returns the HTTP error message.
46 47 48 |
# File 'lib/savon/response.rb', line 46 def http_error @http_error end |
#soap_fault ⇒ Object (readonly)
Returns the SOAP fault message.
38 39 40 |
# File 'lib/savon/response.rb', line 38 def soap_fault @soap_fault end |
Class Method Details
.raise_errors=(raise_errors) ⇒ Object
Sets the global setting of whether to raise errors.
15 16 17 |
# File 'lib/savon/response.rb', line 15 def self.raise_errors=(raise_errors) @@raise_errors = raise_errors end |
.raise_errors? ⇒ Boolean
Returns the global setting of whether to raise errors.
20 21 22 |
# File 'lib/savon/response.rb', line 20 def self.raise_errors? @@raise_errors end |
Instance Method Details
#http_error? ⇒ Boolean
Returns whether there was an HTTP error.
41 42 43 |
# File 'lib/savon/response.rb', line 41 def http_error? !@http_error.blank? end |
#soap_fault? ⇒ Boolean
Returns whether there was a SOAP fault.
33 34 35 |
# File 'lib/savon/response.rb', line 33 def soap_fault? !@soap_fault.blank? end |
#to_hash ⇒ Object
Returns the SOAP response body as a Hash.
49 50 51 |
# File 'lib/savon/response.rb', line 49 def to_hash @body ||= (Crack::XML.parse(@http.body) rescue {}).find_soap_body end |
#to_xml ⇒ Object Also known as: to_s
Returns the SOAP response XML.
54 55 56 |
# File 'lib/savon/response.rb', line 54 def to_xml @http.body end |