Sha256: 08db4f0f2548389946c28bb6a32a7fb3425e189efd0a9cff9a1b828cd0725d64
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
require "savon/error" require "savon/soap/xml" module Savon module SOAP # = Savon::SOAP::Fault # # Represents a SOAP fault. Contains the original <tt>HTTPI::Response</tt>. class Fault < Error # Expects an <tt>HTTPI::Response</tt>. def initialize(http) self.http = http end # Accessor for the <tt>HTTPI::Response</tt>. attr_accessor :http # Returns whether a SOAP fault is present. def present? @present ||= http.body =~ /<soap:Fault>/ end # Returns the SOAP fault message. def to_s return "" unless present? @message ||= message_by_version to_hash[:fault] end # Returns the SOAP response body as a Hash. def to_hash @hash ||= Savon::SOAP::XML.to_hash http.body end private def message_by_version(fault) if fault[:faultcode] "(#{fault[:faultcode]}) #{fault[:faultstring]}" elsif fault[:code] "(#{fault[:code][:value]}) #{fault[:reason][:text]}" end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
savon-0.8.0.beta.3 | lib/savon/soap/fault.rb |
savon-0.8.0.beta.2 | lib/savon/soap/fault.rb |
savon-0.8.0.beta.1 | lib/savon/soap/fault.rb |