Forum: Ruby on Rails Implementing a web service in rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ryan L. (Guest)
on 2009-02-25 02:17
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!
Eric (Guest)
on 2009-02-25 02:41
(Received via mailing list)
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>
Ryan L. (Guest)
on 2009-02-25 02:48
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!
Robert W. (Guest)
on 2009-02-25 03:39
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:
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).
Ryan L. (Guest)
on 2009-02-25 03:49
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:
> 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).
Robert W. (Guest)
on 2009-02-25 19:41
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

Response would then contain PO-XML something like:
<?xml version="1.0" encoding="UTF-8" ?>
<events>
  <event>
    <attribute-1 />
    <attribute-2 />
    <attribute-3 />
    <attribute-4 />
  </event>
  <event>
    <attribute-1 />
    <attribute-2 />
    <attribute-3 />
    <attribute-4 />
  </event>
  <event>
    <attribute-1 />
    <attribute-2 />
    <attribute-3 />
    <attribute-4 />
  </event>
</events>

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.
This topic is locked and can not be replied to.