I have decided to be serious about bough Ruby and rails.
Now I am looking for a webservice tutorial in them.
As I have java background, maybe webservice is not necessary in RoR ?
hoboy Hoboy wrote in post #1008447:
I have decided to be serious about bough Ruby and rails.
Now I am looking for a webservice tutorial in them.
As I have java background, maybe webservice is not necessary in RoR ?
As I’m sure you are aware there are two primary types of web services.
Those being SOAP web services and REST web services. REST is the clear
winner when it comes to web services in Rails. In fact the entire
workflow of Rails is centered around REST.
To being your journey into how Rails implements REST (including REST
based web services) see:
Say you have a Product model that you want to provide access to as a web
service. You’re products_controller.rb file would contain lines that
look something like this:
render :json => @product
Now a consumer of the service may want to get a list of the products
(I’ll use curl as a client here). That would look something like this:
curl -X GET http://example.com/products.json
Once we have the list we could get an individual product by it’s URL:
curl -X GET http://example.com/products/1.json
To create a new product that would look something like:
curl -X POST --data ??? http://example.com/products
where ??? would be the data attributes for the newly created product.
Updating an existing product is just as easy:
curl -X PUT --data ??? http://example.com/products/1
If the client wants (and the server provides) XML the client would just
as for the XML representation instead of JSON:
curl -X GET http://example.com/products.xml