Exception: Savon::SOAP::Fault

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

Overview

Savon::SOAP::Fault

Represents a SOAP fault. Contains the original HTTPI::Response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Fault

Expects an HTTPI::Response.



13
14
15
# File 'lib/savon/soap/fault.rb', line 13

def initialize(http)
  self.http = http
end

Instance Attribute Details

#httpObject

Accessor for the HTTPI::Response.



18
19
20
# File 'lib/savon/soap/fault.rb', line 18

def http
  @http
end

Instance Method Details

#present?Boolean

Returns whether a SOAP fault is present.

Returns:

  • (Boolean)


21
22
23
# File 'lib/savon/soap/fault.rb', line 21

def present?
  @present ||= http.body.include?("Fault>") && (soap1_fault? || soap2_fault?)
end

#to_hashObject

Returns the SOAP response body as a Hash.



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

def to_hash
  @hash ||= Nori.parse(http.body)[:envelope][:body]
end

#to_sObject

Returns the SOAP fault message.



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

def to_s
  return "" unless present?
  @message ||= message_by_version to_hash[:fault]
end