class Savon::SOAP::Fault
Savon::SOAP::Fault¶ ↑
Represents a SOAP fault. Contains the original
HTTPI::Response
.
Attributes
http[RW]
Accessor for the HTTPI::Response
.
Public Class Methods
new(http)
click to toggle source
Expects an HTTPI::Response
.
# File lib/savon/soap/fault.rb, line 13 def initialize(http) self.http = http end
Public Instance Methods
present?()
click to toggle source
Returns whether a SOAP fault is present.
# File lib/savon/soap/fault.rb, line 21 def present? @present ||= http.body.include?("Fault>") && (soap1_fault? || soap2_fault?) end
to_hash()
click to toggle source
Returns the SOAP response body as a Hash.
# File lib/savon/soap/fault.rb, line 32 def to_hash @hash ||= Nori.parse(http.body)[:envelope][:body] end
to_s()
click to toggle source
Returns the SOAP fault message.
# File lib/savon/soap/fault.rb, line 26 def to_s return "" unless present? @message ||= message_by_version to_hash[:fault] end
Private Instance Methods
message_by_version(fault)
click to toggle source
Returns the SOAP fault message by version.
# File lib/savon/soap/fault.rb, line 49 def message_by_version(fault) if fault[:faultcode] "(#{fault[:faultcode]}) #{fault[:faultstring]}" elsif fault[:code] "(#{fault[:code][:value]}) #{fault[:reason][:text]}" end end
soap1_fault?()
click to toggle source
Returns whether the response contains a SOAP 1.1 fault.
# File lib/savon/soap/fault.rb, line 39 def soap1_fault? http.body.include?("faultcode>") && http.body.include?("faultstring>") end
soap2_fault?()
click to toggle source
Returns whether the response contains a SOAP 1.2 fault.
# File lib/savon/soap/fault.rb, line 44 def soap2_fault? http.body.include?("Code>") && http.body.include?("Reason>") end