class Savon::SOAPFault
Attributes
http[R]
nori[R]
xml[R]
Public Class Methods
new(http, nori, xml = nil)
click to toggle source
# File lib/savon/soap_fault.rb, line 15 def initialize(http, nori, xml = nil) @xml = xml @http = http @nori = nori end
present?(http, xml = nil)
click to toggle source
# File lib/savon/soap_fault.rb, line 6 def self.present?(http, xml = nil) xml ||= http.body fault_node = xml.include?("Fault>") soap1_fault = xml.include?("faultcode>") && xml.include?("faultstring>") soap2_fault = xml.include?("Code>") && xml.include?("Reason>") fault_node && (soap1_fault || soap2_fault) end
Public Instance Methods
to_hash()
click to toggle source
# File lib/savon/soap_fault.rb, line 28 def to_hash parsed = nori.parse(xml || http.body) nori.find(parsed, 'Envelope', 'Body') end
to_s()
click to toggle source
# File lib/savon/soap_fault.rb, line 23 def to_s fault = nori.find(to_hash, 'Fault') || nori.find(to_hash, 'ServiceFault') message_by_version(fault) end
Private Instance Methods
message_by_version(fault)
click to toggle source
# File lib/savon/soap_fault.rb, line 35 def message_by_version(fault) if nori.find(fault, 'faultcode') code = nori.find(fault, 'faultcode') text = nori.find(fault, 'faultstring') "(#{code}) #{text}" elsif nori.find(fault, 'Code') code = nori.find(fault, 'Code', 'Value') text = nori.find(fault, 'Reason', 'Text') "(#{code}) #{text}" end end