Accessing the body of a SOAP request using Savon (Ruby on Rails)

I am using Savon Stone in Ruby on Rails to communicate with WSDL WS. Everything works fine, but I want to register the XML request using a custom log, i.e. Not Rails or Savon logger. My code looks something like this:

    response = self.client.request :add_order do
      soap.body = { 
        :indata => {
          "CustomerNo" => config[:kundnr],
          "Pwd" => config[:password],
          "OrderDate" => order["purchase_order_date"].strftime('%Y%m%d')
        }
      }
    end

Access to answers is not a problem, but what about a request? I need to be able to see what was sent in my production environment by running XML in the DB field.

+3
source share
2 answers

XML-. , , Savon . , , , Logger, :debug , .

module DBLogger
  def self.debug(message)
    p message  # replace with custom impl.
  end
end

Savon.configure do |config|
  config.logger = DBLogger
end

, !

+5

, /. Rails.logger , :

client = Savon.client(
  wsdl: 'http://example.com?wsdl',
  log: true,
  logger: Rails.logger,
  log_level: :debug
)

client.call(:example_operation, message: {example: 'example'})

log_level , :) log: true /, URL- .

Savon 2.7.2 .

+2

All Articles