Class: Savon::SOAPFault

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http, nori, xml = nil) ⇒ SOAPFault

Returns a new instance of SOAPFault.



14
15
16
17
18
# File 'lib/savon/soap_fault.rb', line 14

def initialize(http, nori, xml = nil)
  @xml = xml
  @http = http
  @nori = nori
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



20
21
22
# File 'lib/savon/soap_fault.rb', line 20

def http
  @http
end

#noriObject (readonly)

Returns the value of attribute nori.



20
21
22
# File 'lib/savon/soap_fault.rb', line 20

def nori
  @nori
end

#xmlObject (readonly)

Returns the value of attribute xml.



20
21
22
# File 'lib/savon/soap_fault.rb', line 20

def xml
  @xml
end

Class Method Details

.present?(http, xml = nil) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/savon/soap_fault.rb', line 5

def self.present?(http, xml = nil)
  xml ||= http.body
  fault_node  = xml.include?("Fault>")
  soap1_fault = xml.match(/faultcode\/?\>/) && xml.match(/faultstring\/?\>/)
  soap2_fault = xml.include?("Code>") && xml.include?("Reason>")

  fault_node && (soap1_fault || soap2_fault)
end

Instance Method Details

#to_hashObject



27
28
29
30
# File 'lib/savon/soap_fault.rb', line 27

def to_hash
  parsed = nori.parse(xml || http.body)
  nori.find(parsed, 'Envelope', 'Body') || {}
end

#to_sObject



22
23
24
25
# File 'lib/savon/soap_fault.rb', line 22

def to_s
  fault = nori.find(to_hash, 'Fault') || nori.find(to_hash, 'ServiceFault')
  message_by_version(fault)
end