Peter Michaux
2006-Mar-22 06:14 UTC
[Rails] currency conversion webservice in a rails app?
Hi, I''m interested in using a currency conversion web service in my rails app. Does anyone have a free service that they use and like? I found this one http://www.webservicex.net/WS/WSDetails.aspx?CATID=2&WSID=10 I''ve tried to make a simple, plain Ruby script to connect to this and get a conversion rate without success. How do I integrate a webservice into my rails app? I have looked in the Agile Rails book but can only see a tiny bit about this at the end of the web services chapter. All help greatly appreciated. Thanks, Peter
Peter Michaux
2006-Mar-22 17:50 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi,> I''m interested in using a currency conversion web service in my rails app.I''m struggling trying to figure out how to use a webservice and due to the small amount of documention I''ve found I stressing that I won''t get it working. I have tried the following but I get "undefined method `web_client_api'' for #<StoreController:0x26a37f8>". I looked in my environment config files and the actionwebservice package is not being skipped as far as I can tell. (In fact I''ve used it to create a web service server so it must be working.) I have no real idea how to set these few lines of code up and would really appreciate some pointers. Feeling a little let down by page 438 in the Agile Rails book, Peter # in my controller def conversion #con = ActionWebService::Client::Soap.new(WhatGoesHere?, "http://www.webserviceX.NET/ConversionRate") #web_client_api :con, :soap, "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL" web_client_api :con, :soap, "http://www.webserviceX.NET/ConversionRate" con.ConversionRate("CND", "USD") @rate = con end
Kent Sibilev
2006-Mar-22 21:07 UTC
[Rails] Re: currency conversion webservice in a rails app?
ActionWebService::Client::Soap has a special purpose in sense of that you should use it only for calling your own services with defined ActionWebService::API. In order to call third party web services you''re better of using soap4r API directly. Kent. On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote:> > Hi, > > > I''m interested in using a currency conversion web service in my rails > app. > > I''m struggling trying to figure out how to use a webservice and due to > the small amount of documention I''ve found I stressing that I won''t > get it working. I have tried the following but I get "undefined method > `web_client_api'' for #<StoreController:0x26a37f8>". I looked in my > environment config files and the actionwebservice package is not being > skipped as far as I can tell. (In fact I''ve used it to create a web > service server so it must be working.) > > I have no real idea how to set these few lines of code up and would > really appreciate some pointers. > > Feeling a little let down by page 438 in the Agile Rails book, > Peter > > > # in my controller > > def conversion > #con = ActionWebService::Client::Soap.new(WhatGoesHere?, > "http://www.webserviceX.NET/ConversionRate") > #web_client_api :con, :soap, > "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL" > web_client_api :con, :soap, "http://www.webserviceX.NET/ConversionRate > " > > con.ConversionRate("CND", "USD") > @rate = con > end > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060322/2983ba0a/attachment.html
Peter Michaux
2006-Mar-22 22:20 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Kent, Thanks for the reply.> ActionWebService::Client::Soap has a special purpose in sense of that you > should use it only for calling your own services with defined > ActionWebService::API.OK> In order to call third party web services you''re > better of using soap4r API directly.I will look into using the Ruby soap4r library. If I want to use it from inside rails do I have to include it somewhere? Where do I do this? Thanks, Peter
Kent Sibilev
2006-Mar-22 22:24 UTC
[Rails] Re: currency conversion webservice in a rails app?
If you are using ActionWebService then it should be automatically included. Otherwise, my best bet would be config/environment.rb On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote:> > Hi Kent, > > Thanks for the reply. > > > ActionWebService::Client::Soap has a special purpose in sense of that > you > > should use it only for calling your own services with defined > > ActionWebService::API. > > OK > > > In order to call third party web services you''re > > better of using soap4r API directly. > > I will look into using the Ruby soap4r library. If I want to use it > from inside rails do I have to include it somewhere? Where do I do > this? > > Thanks, > Peter > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060322/8dd66d2a/attachment.html
Peter Michaux
2006-Mar-23 00:34 UTC
[Rails] Re: currency conversion webservice in a rails app?
Would you happen to have a simple example you could cut and paste for me? I looked in my Pickaxe book and don''t see soap4r in the index. I can see the SOAP library in the book, Thanks, Peter On 3/22/06, Kent Sibilev <ksruby@gmail.com> wrote:> If you are using ActionWebService then it should be automatically included. > Otherwise, my best bet would be config/environment.rb > > > > On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote: > > > Hi Kent, > > Thanks for the reply. > > > ActionWebService::Client::Soap has a special purpose in sense of that you > > should use it only for calling your own services with defined > > ActionWebService::API. > > OK > > > In order to call third party web services you''re > > better of using soap4r API directly. > > I will look into using the Ruby soap4r library. If I want to use it > from inside rails do I have to include it somewhere? Where do I do > this? > > Thanks, > Peter > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Kent > --- > http://www.datanoise.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Thibaut Barrère
2006-Mar-23 07:14 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Peter here''s one way of doing this : service = SOAP::RPC::Driver.new("http://www.webservicex.net/CurrencyConvertor.asmx","http://www.webserviceX.NET/ <http://www.webservicex.net/CurrencyConvertor.asmx%22,%22http://www.webserviceX.NET/> ") service.default_encodingstyle SOAP::EncodingStyle::ASPDotNetHandler::Namespace service.add_method_with_soapaction("ConversionRate", "http://www.webserviceX.NET/ConversionRate<http://www.webservicex.net/ConversionRate>", "FromCurrency", "ToCurrency") rate = service.ConversionRate("EUR","GBP") cheers Thibaut -- [blog] http://www.dotnetguru2.org/tbarrere On 3/23/06, Peter Michaux <petermichaux@gmail.com> wrote:> > Would you happen to have a simple example you could cut and paste for > me? I looked in my Pickaxe book and don''t see soap4r in the index. I > can see the SOAP library in the book, > > Thanks, > Peter > > On 3/22/06, Kent Sibilev <ksruby@gmail.com> wrote: > > If you are using ActionWebService then it should be automatically > included. > > Otherwise, my best bet would be config/environment.rb > > > > > > > > On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote: > > > > > Hi Kent, > > > > Thanks for the reply. > > > > > ActionWebService::Client::Soap has a special purpose in sense of that > you > > > should use it only for calling your own services with defined > > > ActionWebService::API. > > > > OK > > > > > In order to call third party web services you''re > > > better of using soap4r API directly. > > > > I will look into using the Ruby soap4r library. If I want to use it > > from inside rails do I have to include it somewhere? Where do I do > > this? > > > > Thanks, > > Peter > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > -- > > Kent > > --- > > http://www.datanoise.com > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/5d98f131/attachment.html
Thibaut Barrère
2006-Mar-23 09:37 UTC
[Rails] Re: currency conversion webservice in a rails app?
you may also want to have a look at this page (which I just discovered) http://wiki.rubyonrails.org/rails/pages/How+To+Consume+.NET+WebServices/ HTH Thibaut -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/ab5acb09/attachment.html
Peter Michaux
2006-Mar-23 16:38 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Thibaut, Thanks for the code! I tried it and no matter which currencies combination I try I get a rate of zero. Did you try this and get a different result? It maybe that the web service doesn''t work but I hope not. Thanks, Peter On 3/22/06, Thibaut Barr?re <thibaut.barrere@gmail.com> wrote:> Hi Peter > > here''s one way of doing this : > > service = SOAP::RPC::Driver.new(" > http://www.webservicex.net/CurrencyConvertor.asmx","http://www.webserviceX.NET/ > ") > service.default_encodingstyle > SOAP::EncodingStyle::ASPDotNetHandler::Namespace > service.add_method_with_soapaction("ConversionRate", " > http://www.webserviceX.NET/ConversionRate", "FromCurrency", > "ToCurrency") > > > rate = service.ConversionRate("EUR","GBP")cheers > > Thibaut > -- > [blog] http://www.dotnetguru2.org/tbarrere > > > On 3/23/06, Peter Michaux <petermichaux@gmail.com> wrote: > > Would you happen to have a simple example you could cut and paste for > > me? I looked in my Pickaxe book and don''t see soap4r in the index. I > > can see the SOAP library in the book, > > > > Thanks, > > Peter > > > > On 3/22/06, Kent Sibilev < ksruby@gmail.com> wrote: > > > If you are using ActionWebService then it should be automatically > included. > > > Otherwise, my best bet would be config/environment.rb > > > > > > > > > > > > On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote: > > > > > > > Hi Kent, > > > > > > Thanks for the reply. > > > > > > > ActionWebService::Client::Soap has a special purpose in sense of that > you > > > > should use it only for calling your own services with defined > > > > ActionWebService::API. > > > > > > OK > > > > > > > In order to call third party web services you''re > > > > better of using soap4r API directly. > > > > > > I will look into using the Ruby soap4r library. If I want to use it > > > from inside rails do I have to include it somewhere? Where do I do > > > this? > > > > > > Thanks, > > > Peter > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > -- > > > Kent > > > --- > > > http://www.datanoise.com > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Thibaut Barrère
2006-Mar-23 16:59 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Peter I had this zero rate a some point, can''t remember exactly under which circumstances. I finally managed to get the good conversion rate - I''ll check my code back at home. Three ideas until then: - try the code in IRB to see what''s actually returned - try adding service.wiredump_dev = STDERR to dump the communication (on the webservice webpage you''ll see the expected input and output) - try ConversionRate(xxxx).to_f Thibaut -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/201e43a4/attachment.html
Ken Kousen
2006-Mar-23 23:05 UTC
[Rails] Re: currency conversion webservice in a rails app?
I just wanted to mention that the beta book "Enterprise Integration with Ruby" by Maik Schmidt (available at the Pragmatic Programmers web site, as usual) has an extensive section on processing XML files. It also discusses soap4r, REXML, and any other way of creating or consuming web services that you can think of. Like most of their Beta Books, it''s awfully close to being a fully polished product. In short, that book rocks. Ken -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen@kousenit.com -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Peter Michaux Sent: Wednesday, March 22, 2006 7:34 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Re: currency conversion webservice in a rails app? Would you happen to have a simple example you could cut and paste for me? I looked in my Pickaxe book and don''t see soap4r in the index. I can see the SOAP library in the book, Thanks, Peter On 3/22/06, Kent Sibilev <ksruby@gmail.com> wrote:> If you are using ActionWebService then it should be automaticallyincluded.> Otherwise, my best bet would be config/environment.rb > > > > On 3/22/06, Peter Michaux <petermichaux@gmail.com> wrote: > > > Hi Kent, > > Thanks for the reply. > > > ActionWebService::Client::Soap has a special purpose in sense of thatyou> > should use it only for calling your own services with defined > > ActionWebService::API. > > OK > > > In order to call third party web services you''re > > better of using soap4r API directly. > > I will look into using the Ruby soap4r library. If I want to use it > from inside rails do I have to include it somewhere? Where do I do > this? > > Thanks, > Peter > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Kent > --- > http://www.datanoise.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Peter Michaux
2006-Mar-24 06:34 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Thibaut, I''ve been trying to get this working. No luck yet. With wiredump it looks like the webservice really is returning zero. Any other ideas? Thanks, Peter On 3/23/06, Thibaut Barr?re <thibaut.barrere@gmail.com> wrote:> Hi Peter > > I had this zero rate a some point, can''t remember exactly under which > circumstances. I finally managed to get the good conversion rate - I''ll > check my code back at home. > > Three ideas until then: > - try the code in IRB to see what''s actually returned > - try adding service.wiredump_dev = STDERR to dump the communication (on the > webservice webpage you''ll see the expected input and output) > - try ConversionRate(xxxx).to_f > > Thibaut > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Kent Sibilev
2006-Mar-24 22:12 UTC
[Rails] Re: currency conversion webservice in a rails app?
It works for me. What version of soap4r are you using? $ ruby -rsoap/soap -e ''puts SOAP::Version'' 1.5.5 On 3/24/06, Peter Michaux <petermichaux@gmail.com> wrote:> > Hi Thibaut, > > I''ve been trying to get this working. No luck yet. With wiredump it > looks like the webservice really is returning zero. Any other ideas? > > Thanks, > Peter > > > On 3/23/06, Thibaut Barr?re <thibaut.barrere@gmail.com> wrote: > > Hi Peter > > > > I had this zero rate a some point, can''t remember exactly under which > > circumstances. I finally managed to get the good conversion rate - I''ll > > check my code back at home. > > > > Three ideas until then: > > - try the code in IRB to see what''s actually returned > > - try adding service.wiredump_dev = STDERR to dump the communication (on > the > > webservice webpage you''ll see the expected input and output) > > - try ConversionRate(xxxx).to_f > > > > Thibaut > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/790ad69b/attachment.html
Peter Michaux
2006-Mar-24 22:31 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Kent, It works? You got a number other than zero? $ ruby -rsoap/soap -e ''puts SOAP::Version'' 1.5.3-ruby1.8.2 Does this mean I need an upgrade? It would be strange since the Ruby runs without error. It is the SOAP response that has the zero. I realize it must be something wrong on my end. Maybe I have a typo. Did you cut and paste the code? What is soap4r? Is it just a catchy phrase meaning SOAP in the Ruby environment? Or is it a library? Thanks, Peter On 3/24/06, Kent Sibilev <ksruby@gmail.com> wrote:> It works for me. What version of soap4r are you using? > > $ ruby -rsoap/soap -e ''puts SOAP::Version'' > 1.5.5 > > > > On 3/24/06, Peter Michaux < petermichaux@gmail.com> wrote: > > Hi Thibaut, > > > > I''ve been trying to get this working. No luck yet. With wiredump it > > looks like the webservice really is returning zero. Any other ideas? > > > > Thanks, > > Peter > > > > > > On 3/23/06, Thibaut Barr?re <thibaut.barrere@gmail.com> wrote: > > > Hi Peter > > > > > > I had this zero rate a some point, can''t remember exactly under which > > > circumstances. I finally managed to get the good conversion rate - I''ll > > > check my code back at home. > > > > > > Three ideas until then: > > > - try the code in IRB to see what''s actually returned > > > - try adding service.wiredump_dev = STDERR to dump the communication (on > the > > > webservice webpage you''ll see the expected input and output) > > > - try ConversionRate(xxxx).to_f > > > > > > Thibaut > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > -- > > Kent > --- > http://www.datanoise.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Peter Michaux
2006-Mar-24 23:15 UTC
[Rails] Re: currency conversion webservice in a rails app?
Hi Kent, I upgraded from Ruby 1.8.2 to 1.8.4 and now I have SOAP 1.5.5. And the example works! Thanks. Thanks to Thibaut also. This is a major mystery and stress I hope is now over. Thanks again, Peter On 3/24/06, Peter Michaux <petermichaux@gmail.com> wrote:> Hi Kent, > > It works? You got a number other than zero? > > $ ruby -rsoap/soap -e ''puts SOAP::Version'' > 1.5.3-ruby1.8.2 > > Does this mean I need an upgrade? It would be strange since the Ruby > runs without error. It is the SOAP response that has the zero. I > realize it must be something wrong on my end. Maybe I have a typo. Did > you cut and paste the code? > > What is soap4r? Is it just a catchy phrase meaning SOAP in the Ruby > environment? Or is it a library? > > Thanks, > Peter > > > On 3/24/06, Kent Sibilev <ksruby@gmail.com> wrote: > > It works for me. What version of soap4r are you using? > > > > $ ruby -rsoap/soap -e ''puts SOAP::Version'' > > 1.5.5 > > > > > > > > On 3/24/06, Peter Michaux < petermichaux@gmail.com> wrote: > > > Hi Thibaut, > > > > > > I''ve been trying to get this working. No luck yet. With wiredump it > > > looks like the webservice really is returning zero. Any other ideas? > > > > > > Thanks, > > > Peter > > > > > > > > > On 3/23/06, Thibaut Barr?re <thibaut.barrere@gmail.com> wrote: > > > > Hi Peter > > > > > > > > I had this zero rate a some point, can''t remember exactly under which > > > > circumstances. I finally managed to get the good conversion rate - I''ll > > > > check my code back at home. > > > > > > > > Three ideas until then: > > > > - try the code in IRB to see what''s actually returned > > > > - try adding service.wiredump_dev = STDERR to dump the communication (on > > the > > > > webservice webpage you''ll see the expected input and output) > > > > - try ConversionRate(xxxx).to_f > > > > > > > > Thibaut > > > > > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > -- > > > > Kent > > --- > > http://www.datanoise.com > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > >