class Starapi::SoapServiceFacade::Base
Public Instance Methods
construct_envelope(&block)
click to toggle source
# File lib/starapi/soap_service_facade/base.rb, line 7 def construct_envelope(&block) Nokogiri::XML::Builder.new do |xml| xml.Envelope("xmlns:soap12" => "http://www.w3.org/2003/05/soap-envelope", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema") do xml.parent.namespace = xml.parent.namespace_definitions.first xml['soap12'].Body(&block) end end end
handle_error(response)
click to toggle source
# File lib/starapi/soap_service_facade/base.rb, line 28 def handle_error(response) xml = Nokogiri::XML(response.body) xpath = '/soap:Envelope/soap:Body/soap:Fault//soap:Text' msg = xml.xpath(xpath).text # TODO: Capture any app-specific exception messages here. # For example, if the server returns a Fault when a search # has no results, you might rather return an empty array. raise SoapServiceFacade::SoapError.new("Error from server: #{msg}") end
process_response(response)
click to toggle source
# File lib/starapi/soap_service_facade/base.rb, line 18 def process_response(response) @last_response = response if response.body =~ /soap:Fault/ then handle_error(response) else return response end end