title: View Savon Request XML without Sending to Server
body: <p>I'm using the Savon gem to make a SOAP request using code similar to what's below. It's working, but I would like to view/capture the request XML without actually making a call to their server. I can view it now after a request is made by sticking a debugger line after the request and inspecting the client variable. </p>
  
  <p>Does anyone know of a way to view the request XML without actually making a request? I want to be able to validate the XML against a schema using Cucumber or Rspec.</p>
  
  <pre><code>client = Savon::Client.new do |wsdl, http|
    wsdl.document = "http://fakesite.org/fake.asmx?wsdl"
  end
  
  client.request(:testpostdata, :xmlns =&gt; "http://fakesite.org/") do
    soap.header = { :cAuthentication =&gt; {"UserName" =&gt; "MyName", "Password" =&gt; "MyPassword" } }
    soap.body = { :xml_data =&gt; to_xml }
  end
  </code></pre>