class ApiBanking::Soap12Client

Private Class Methods

add_soap_headers(options, soapAction) click to toggle source
# File lib/api_banking/soap/soap_client.rb, line 107
def self.add_soap_headers(options, soapAction)
  options[:headers] = {'Content-Type' => "application/xml; charset=utf-8"}

  # SOAPAction header is not allowed for Soap12
  # options[:headers][:SOAPAction] = data.doc.at_xpath('/soapenv12:Envelope/soapenv12:Body/*', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope').name

end
construct_envelope(&block) click to toggle source
# File lib/api_banking/soap/soap_client.rb, line 115
def self.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'].Header
      xml['soap12'].Body(&block)
    end
  end
end
parse_fault(reply) click to toggle source
# File lib/api_banking/soap/soap_client.rb, line 127
def self.parse_fault(reply)
  code   = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
  subcode   = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
  reasonText   = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Reason/soapenv12:Text', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))

  code ||= 'ns:E500'  # in certain cases, a fault code isn't set by the server
  return Fault.new(code, subcode, reasonText)
end