In situation, when I need a webservice client, which will be used by some action controllers, how should it be implemented? As it will have some constant values (addres, parameters names) and session key, refreshed every 30 minutes, I guess model stored in database isn't the best solution. What is the best practice?
+2
A:
Built the web service consumer as a library and place it in your /lib directory.
I would also recommend HTTParty for very simple consumption of web services. You could easily build a library to handle the task, a simple class with a few methods and toss it in your /lib directory and be on your way.
Good luck!
mwilliams
2008-12-03 19:01:46
Gem you're recommending is really superb. But I'm still unsure where to store shared session key. As it expires every 30 minutes, and I'll perform about 100 requests in this time, storing it somewhere will save lots of key obtaining requests. Do you think local YAML file will fit?
mcveat
2008-12-03 20:02:26
Create a model to store the key, once it's queried you can cache it for as long as you need it. Or you can go the way of a YAML file as well. This screencast should make it an easy task: http://railscasts.com/episodes/85-yaml-configuration-file and see which works best for you.
mwilliams
2008-12-03 21:32:38
A:
Rails 1.x used to have "actionwebservices" builtin but it has been removed from Rails 2.x. The last time I did this was to build an SSO server implemented as classes using XML-RPC. The code is not public unfortunately (done internally for my employer) but was under 1k LOC incl. comments... Plain Ruby.
Now, I'd probably use a lightweight framework like Sinatra or an equivalent.
Keltia
2008-12-08 14:00:42