Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Ruby和Savon执行简单的web服务客户端_Ruby_Web Services_Savon - Fatal编程技术网

如何使用Ruby和Savon执行简单的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.

我正在尝试使用Savon在Ruby中开发一个简单的web服务客户机示例

到目前为止,我得到的是:

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'
在你的档案里