Class: Savon::SOAPFault
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#nori ⇒ Object
readonly
Returns the value of attribute nori.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(http, nori, xml = nil) ⇒ SOAPFault
constructor
A new instance of SOAPFault.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(http, nori, xml = nil) ⇒ SOAPFault
Returns a new instance of SOAPFault.
21 22 23 24 25 |
# File 'lib/savon/soap_fault.rb', line 21 def initialize(http, nori, xml = nil) @xml = xml @http = http @nori = nori end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
27 28 29 |
# File 'lib/savon/soap_fault.rb', line 27 def http @http end |
#nori ⇒ Object (readonly)
Returns the value of attribute nori.
27 28 29 |
# File 'lib/savon/soap_fault.rb', line 27 def nori @nori end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
27 28 29 |
# File 'lib/savon/soap_fault.rb', line 27 def xml @xml end |
Class Method Details
.present?(http, xml = nil) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/savon/soap_fault.rb', line 5 def self.present?(http, xml = nil) xml_orig ||= http.body if xml_orig.valid_encoding? xml = xml_orig else xml = xml_orig.encode( 'UTF-8', "ISO-8859-1", invalid: :replace, undef: :replace, replace: '' ) end 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_hash ⇒ Object
34 35 36 37 |
# File 'lib/savon/soap_fault.rb', line 34 def to_hash parsed = nori.parse(xml || http.body) nori.find(parsed, 'Envelope', 'Body') || {} end |
#to_s ⇒ Object
29 30 31 32 |
# File 'lib/savon/soap_fault.rb', line 29 def to_s fault = nori.find(to_hash, 'Fault') || nori.find(to_hash, 'ServiceFault') (fault) end |