============================ Ruby + Savon + Soap ============================ .. contents:: Introduction ---------------------------- 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`_. .. _SOAP: http://www.w3.org/TR/soap/ .. _soapUI: http://www.eviware.com/ .. _WSDL documents: http://www.w3.org/TR/wsdl Installation ---------------------------- .. code-block:: bash $gem install savon Runtime dependencies ---------------------------- - Builder ~> 2.1.2 - Crack ~> 0.1.8 - HTTPI >= 0.7.5 - Gyoku >= 0.1.1 Simple example ---------------------------- .. code-block:: ruby 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 = " 7950801 " 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 Reference ---------------------------- #. http://rubiii.github.com/savon/