Five lines of code are enough to write a Web Service client in Ruby:
require 'soap/wsdlDriver'
wsdl = 'http://www.webservicex.com/CurrencyConvertor.asmx?wsdl'
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
input = {:FromCurrency => 'USD', :ToCurrency => 'EUR' }
print driver.ConversionRate(input).conversionRateResult
Save this file as "currency.rb" and run it from command line with:
ruby currency.rb
No comments:
Post a Comment