# Web Services

**URL:** <https://www.ruby-forum.com/t/web-services/178430>\
**Category:** Rails\
**Created:** [November 4, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/web-services/178430 "2009-11-04T15:26:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Elliott\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@Steven\_Elliott\_Jr](https://www.ruby-forum.com/u/Steven_Elliott_Jr)\
**Post date:** [November 4, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/web-services/178430/1 "2009-11-04T15:26:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steven\_Elliott\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@Steven\_Elliott\_Jr](https://www.ruby-forum.com/u/Steven_Elliott_Jr)\
**Post date:** [November 4, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/web-services/178430/2 "2009-11-04T20:11:08Z")

</div>

Hi Steve,

On Wed, 2009-11-04 at 06:24 -0800, Steven Elliott Jr wrote:

> 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 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](http://agilewebdevelopment.com/plugins/action_web_services)

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![Steven\_Elliott\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@Steven\_Elliott\_Jr](https://www.ruby-forum.com/u/Steven_Elliott_Jr)\
**Post date:** [November 4, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/web-services/178430/3 "2009-11-04T20:40:59Z")

</div>

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

On Wed, Nov 4, 2009 at 2:09 PM, bill walton [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > I was thinking just a very SOAP type of thing would be  
> > HTH,  
> > Bill
> 
> >

–  
Steven Elliott Jr

---

<div class="post-metadata">

**Author:** ![Steven\_Elliott\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@Steven\_Elliott\_Jr](https://www.ruby-forum.com/u/Steven_Elliott_Jr)\
**Post date:** [November 5, 2009, 10:53am UTC](https://www.ruby-forum.com/t/web-services/178430/4 "2009-11-05T10:53:13Z")

</div>

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

On Nov 4, 7:24 pm, Steven Elliott Jr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
