How can I create a web servic开发者_运维问答e using Ruby on Rails? Please give an example.
Disclaimer: This answer is not about rails, but about ruby web services in general.
I found this talk about ruby web services with sinatra rather refreshing:
http://www.techscreencast.com/language/ruby/lightweight-web-services-with-sinatra-and-restclient---adam-wiggins--blake-mizerany/1456
The hook:
Tired of web apps written in Ruby being big, slow, and complex? Then try subdividing your problem space by slicing up your app into a set of lightweight web services.
In this talk, Adam Wiggins, author of the RestClient rubygem, and Blake Mizerany, author of the Sinatra microframework, will introduce you to these lean-and-mean tools and show you that Ruby web apps can indeed be small, fast, and memory-efficient.
Then we'll show how lightweight web services, communicating with each other via REST calls, can be assembled into a larger software system. Using real-world examples from Heroku, we'll show how a service-based architecture has the potential to be more scalable, more maintainable, and just more fun than a monolithic one.
dont use ActionWebService, use ActiveResource. just google 'activeresource' and you'll find tons of resources on how to create rest webservices with it.
edit : screencast here http://railscasts.com/episodes/95-more-on-activeresource
edit #2: didn't state why you should use activeresource over actionwebservice... well actionwebservice has been removed around rails 2.0. but if you "really" need to use it, you might wanna try the one from datanoise (http://github.com/datanoise/actionwebservice)
精彩评论