Contents
Savon is a SOAP client library for Ruby. It’s goal is to provide a lightweight and easy to use alternative to soap4r. If you’re starting to use Savon, please make sure to read this guide and make yourself familiar with SOAP itself, WSDL documents and tools like soapUI.
$gem install savon
require 'rubygems'
require 'savon'
require 'rexml/document'
include REXML
client = Savon::Client.new do
wsdl.document = "http://www.abc.com/service?wsdl"
end
response = client.request :man, :findDetailsById do
soap.body = "
<id>7950801</id>
"
end
#puts response.to_xml
xmldoc = REXML::Document.new(response.to_xml)
currentDate = Time.new
filesuffix = currentDate.strftime("%Y%m%d%H%M%S")
resultfile_path = "result/response_" + filesuffix + ".xml"
file = File.new("#{resultfile_path}","w+")
XPath.each(xmldoc, "//return/*") do |e|
file << e
end