Class: Savon::SOAP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/soap/response.rb

Overview

Savon::SOAP::Response

Represents the SOAP response and contains the HTTP response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Expects an HTTPI::Response and handles errors.



14
15
16
17
# File 'lib/savon/soap/response.rb', line 14

def initialize(response)
  self.http = response
  raise_errors if Savon.raise_errors?
end

Instance Attribute Details

#httpObject

Returns the value of attribute http.



19
20
21
# File 'lib/savon/soap/response.rb', line 19

def http
  @http
end

Instance Method Details

#basic_hashObject

Returns the complete SOAP response XML without normalization.



62
63
64
# File 'lib/savon/soap/response.rb', line 62

def basic_hash
  @basic_hash ||= Savon::SOAP::XML.parse http.body
end

#headerObject

Returns the SOAP response header as a Hash.



47
48
49
# File 'lib/savon/soap/response.rb', line 47

def header
  @header_hash ||= basic_hash.find_soap_header
end

#http_errorObject

Returns the Savon::HTTP::Error.



42
43
44
# File 'lib/savon/soap/response.rb', line 42

def http_error
  @http_error ||= HTTP::Error.new http
end

#http_error?Boolean

Returns whether there was an HTTP error.

Returns:

  • (Boolean)


37
38
39
# File 'lib/savon/soap/response.rb', line 37

def http_error?
  http_error.present?
end

#soap_faultObject

Returns the Savon::SOAP::Fault.



32
33
34
# File 'lib/savon/soap/response.rb', line 32

def soap_fault
  @soap_fault ||= Fault.new http
end

#soap_fault?Boolean

Returns whether there was a SOAP fault.

Returns:

  • (Boolean)


27
28
29
# File 'lib/savon/soap/response.rb', line 27

def soap_fault?
  soap_fault.present?
end

#success?Boolean

Returns whether the request was successful.

Returns:

  • (Boolean)


22
23
24
# File 'lib/savon/soap/response.rb', line 22

def success?
  !soap_fault? && !http_error?
end

#to_array(*path) ⇒ Object

Returns the SOAP response body as an Array.



57
58
59
# File 'lib/savon/soap/response.rb', line 57

def to_array(*path)
  Savon::SOAP::XML.to_array to_hash, *path
end

#to_hashObject

Returns the SOAP response body as a Hash.



52
53
54
# File 'lib/savon/soap/response.rb', line 52

def to_hash
  @hash ||= Savon::SOAP::XML.to_hash basic_hash
end

#to_xmlObject

Returns the SOAP response XML.



67
68
69
# File 'lib/savon/soap/response.rb', line 67

def to_xml
  http.body
end