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.
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
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.
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,
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 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.
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)
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.
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?