# Implementing a web service in rails

**URL:** <https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282>\
**Category:** Rails\
**Created:** [February 25, 2009, 1:17am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282 "2009-02-25T01:17:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 1:17am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/1 "2009-02-25T01:17:47Z")

</div>

Hi all,

I need to implement a web service in rails with the following signature:

string ReceiveEvents (string A, string B, string C).

As you can see, it is basically a method that takes in three strings and  
returns a string. I’m 99% sure the call is made via SOAP.

I’ve spent all day searching around (SOAP4R, AWS, . . .) but have not  
been able to find any compelling help.

Any advice is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 1:41am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/2 "2009-02-25T01:41:55Z")

</div>

Help and advice for what? I can’t find a question in there.

-e

On Feb 24, 4:17 pm, Ryan L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 1:48am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/3 "2009-02-25T01:48:25Z")

</div>

To clear things up:

I do not know where to get started making this SOAP webservice in Rails.  
I’m looking for some preliminary advice or a tutorial on creating a soap  
webservice in rails. I know I should be moving to REST, but a platform  
our system must interact with uses SOAP and I absolutely must support  
this call.

So:

1. How do I implement a SOAP web service in rails?
2. Is there a way to do this with REST?
3. Does anyone have a good tutorial to do this?

Thanks again

Ryan L. wrote:

> Hi all,
> 
> I need to implement a web service in rails with the following signature:
> 
> string ReceiveEvents (string A, string B, string C).
> 
> As you can see, it is basically a method that takes in three strings and  
> returns a string. I’m 99% sure the call is made via SOAP.
> 
> I’ve spent all day searching around (SOAP4R, AWS, . . .) but have not  
> been able to find any compelling help.
> 
> Any advice is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 2:49am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/4 "2009-02-25T02:49:43Z")

</div>

Thanks Robert,

I’ll look into your tips tomorrow and let you know how it goes.

I actually need to provide the web service. I would like to use REST,  
but my web service must fit the signature above. The client that wants  
to consume this web service uses SOAP. I’ve had no problem consuming  
SOAP webservices…but need to figure out how to provide one with that  
signature (or if there is a way in REST to match that signature).

Thanks

Robert W. wrote:

> Ryan L. wrote:
> 
> > To clear things up:
> > 
> > I do not know where to get started making this SOAP web service in Rails.  
> > I’m looking for some preliminary advice or a tutorial on creating a soap  
> > webservice in rails. I know I should be moving to REST, but a platform  
> > our system must interact with uses SOAP and I absolutely must support  
> > this call.
> 
> I’m a little confused; Are you wanting to provide the web service or  
> consume an existing web service.
> 
> If it’s the former then I would recommend forgetting about SOAP and  
> implement a REST web service for your client. Basically just build a  
> Rails application the normal Rails 2.x way by providing the proper  
> response formats for exposing actions as web services.
> 
> If it’s the later, and the service you’re trying to consume is a SOAP  
> service, then you stuck and have to use SOAP.
> 
> I’m guessing what your showing there is likely an existing web service,  
> probably written in Java, since most Java people haven’t yet figured out  
> that REST is the future of web services.
> 
> If my assumption is correct then take a look here:  
> [GitHub - datanoise/actionwebservice: This project is discontinued](http://github.com/datanoise/actionwebservice/tree/master)
> 
> I have not used this, but this question keeps getting posted  
> over-and-over and this is the canned answer to the “I need SOAP web  
> services” question. However, if you ever get deep into SOAP you’ll  
> quickly begin to realize why it is so far off the radar of typical Rails  
> developers.
> 
> Also, just so you know, I’m forced to deal with SOAP on an almost daily  
> basis (in Java) so I’m not speaking from inexperience.
> 
> P.S. Since the the original acronym for SOAP complete fell apart over  
> the years, I propose we redefine SOAP (Simple Object Access Protocol) as  
> (Supremely Over-engineered Abstraction Protocol).

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 2:39am UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/5 "2009-02-25T02:39:02Z")

</div>

Ryan L. wrote:

> To clear things up:
> 
> I do not know where to get started making this SOAP web service in Rails.  
> I’m looking for some preliminary advice or a tutorial on creating a soap  
> webservice in rails. I know I should be moving to REST, but a platform  
> our system must interact with uses SOAP and I absolutely must support  
> this call.

I’m a little confused; Are you wanting to provide the web service or  
consume an existing web service.

If it’s the former then I would recommend forgetting about SOAP and  
implement a REST web service for your client. Basically just build a  
Rails application the normal Rails 2.x way by providing the proper  
response formats for exposing actions as web services.

If it’s the later, and the service you’re trying to consume is a SOAP  
service, then you stuck and have to use SOAP.

I’m guessing what your showing there is likely an existing web service,  
probably written in Java, since most Java people haven’t yet figured out  
that REST is the future of web services.

If my assumption is correct then take a look here:

> **[GitHub - datanoise/actionwebservice: This project is discontinued](https://github.com/datanoise/actionwebservice/tree/master)**
>
> master

I have not used this, but this question keeps getting posted  
over-and-over and this is the canned answer to the “I need SOAP web  
services” question. However, if you ever get deep into SOAP you’ll  
quickly begin to realize why it is so far off the radar of typical Rails  
developers.

Also, just so you know, I’m forced to deal with SOAP on an almost daily  
basis (in Java) so I’m not speaking from inexperience.

P.S. Since the the original acronym for SOAP complete fell apart over  
the years, I propose we redefine SOAP (Simple Object Access Protocol) as  
(Supremely Over-engineered Abstraction Protocol).

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [February 25, 2009, 6:41pm UTC](https://www.ruby-forum.com/t/implementing-a-web-service-in-rails/161282/6 "2009-02-25T18:41:56Z")

</div>

Ryan L. wrote:

> Thanks Robert,
> 
> I’ll look into your tips tomorrow and let you know how it goes.
> 
> I actually need to provide the web service. I would like to use REST,  
> but my web service must fit the signature above. The client that wants  
> to consume this web service uses SOAP. I’ve had no problem consuming  
> SOAP webservices…but need to figure out how to provide one with that  
> signature (or if there is a way in REST to match that signature).

SOAP:  
String receiveEvents (String a, String b, String c); // Assuming Java  
style syntax

REST:  
GET: [http://example.com/events.xml?a=a&b=b&c=c](http://example.com/events.xml?a=a&b=b&c=c)

Response would then contain PO-XML something like:

\<?xml version="1.0" encoding="UTF-8" ?\> 

Or in case of error you get back an HTTP error response.

Basically it just HTTP like any other web resource. Also the .xml is not  
required if the ACCEPTS header is set properly in the HTTP request. But,  
you can read up on REST how how it works on you own. It can’t easily be  
fully explained in the context of a forum.

However, I’m pretty sure that’s not what your consumer is going to want  
to hear. They likely won’t understand that REST actually does work.
