Web Services

Hello,

Has anyone had to write a web service in Rails? If so, I'd love to get
some information from you as to where to begin.

I have recently started introducing Rails into the enterprise at my
office. It has been met with some hesitation by the older developers
(all using .NET). Anyway, a requirement came up to write some web
services that allow another web company to consume certain
information. Basically i need to set up a registration service for
members and then a log in service where we can authenticate users...
we'll be storing the credentials on our side.

Basically it breaks down like this:

Registration
     other company will pass last 4 of SSN,
     Zip code,
     Email Address,
     Password
Our Response
     Already registered (boolean): true if already registered, false
if not
if registered
        the registered email address (string)
        the registered password (string)
        other company can then use these to send them a forgot
password email

Login
other company will pass
    email (string)
    password (string)
Our response
    allowed (boolean)
    other information...

We're storing all of our data on SQL Server 2008 but that's not a big
issue. I wanted to be able to show Rails' capability of quickly and
easily handling this standard enterprise requirement. I'd love to hear
some thoughts from anyone who has done this type of thing before. I am
really trying to avoid using Windows Communication Foundation for this
type of thing. I was thinking just a very SOAP type of thing would be
the best approach.

Thanks!
Steve

Hi Steve,

Has anyone had to write a web service in Rails? If so, I'd love to get
some information from you as to where to begin.

<snip>

I was thinking just a very SOAP type of thing would be
the best approach.

I'd recommend starting with "RESTful Web Services" by Leonard Richardson
and Sam Ruby, published by O'Reilly.

Rails today has a very strong preference for REST over SOAP when it
comes to Web Services. Having experience with both, I can say without
equivocation that REST is the way to go if you can. If you can't, use
the plugin at http://agilewebdevelopment.com/plugins/action_web_services

HTH,
Bill

Hi Bill,

Thanks for the email. Ya I am looking into RESTful now thinking that might be the way to go. There is not too much on the web out there but I saw a book from Apress “Practical Rest On Rails 2” I am thinking of taking a look at that.

Thanks again,
Steve

Hi Steven,

If you are using rails 2.3.x it already create web services for you as
default(although its simple), RESTFull approach. In controller you
might have seen this line,

respond_to do |format|
     format.html # index.html.erb
     format.xml { render :xml => @object }
end

there format.xml { render :xml => @object } means it returns a
RESTFull xml file. (or even you can post as xml files)

hope this helps,

cheers
sameera