如何使用Ruby和Savon执行简单的web服务客户端
我正在尝试使用Savon在Ruby中开发一个简单的web服务客户机示例 到目前为止,我得到的是:如何使用Ruby和Savon执行简单的web服务客户端,ruby,web-services,savon,Ruby,Web Services,Savon,我正在尝试使用Savon在Ruby中开发一个简单的web服务客户机示例 到目前为止,我得到的是: class WebServiceController < ApplicationController def index puts "web_service: IN" client = Savon::Client.new do wsdl.document = "http://www.webservicex.com/CurrencyConvertor.
class WebServiceController < ApplicationController
def index
puts "web_service: IN"
client = Savon::Client.new do
wsdl.document = "http://www.webservicex.com/CurrencyConvertor.asmx?wsdl"
end
response = client.request :conversion_rate do
soap.body = {
:from_currency => 'USD',
:to_currency => 'EUR'
}
end
puts response.to_hash;
render :text => response.to_hash.to_s
end
end
class WebServiceController“USD”,
:对欧元汇率=>“欧元”
}
结束
将response.to放入_散列;
render:text=>response.to_hash.to_
结束
结束
但是,当我运行该代码时,我得到:
未初始化的常量Savon::Client
我想我得给Savon添加一些参考?(我已经安装了相应的gem)
此外:我在该web服务中做的事情是否正确?它应该起作用吗
谢谢你抽出时间 如果这是Rails 3应用程序,请将其添加到您的
GEM文件中
:
gem 'savon'
然后,运行
bundle install
并重新启动开发服务器。如果这是Rails 3应用程序,请将其添加到您的GEM文件中:
gem 'savon'
然后,运行bundle install
并重新启动开发服务器。我想您已经添加了
require 'savon'
在您的文件中的某个地方?我想您已经添加了
require 'savon'
在你的档案里