1

I'm trying to develop a simple example of a web service client in Ruby using Savon.

This is what I got so far:

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

However, when I run that code I get:

uninitialized constant Savon::Client

I guess I have to add some reference to Savon? (I already installed the corresponding gem).

In addition: am I doing the right thing in that web service? Should it work?

Thank you for your time!

tiiin4
  • 539
  • 4
  • 7
  • 19

2 Answers2

1

If this is a Rails 3 application, add this onto your Gemfile:

gem 'savon'

Then, run bundle install and restart your development server.

changelog
  • 4,646
  • 4
  • 35
  • 62
0

I suppose you've added

require 'savon'

somewhere in your file?

Steffen Roller
  • 3,464
  • 25
  • 43