views:

7631

answers:

6

A client of mine has asked me to integrate a 3rd party API into their Rails app. The only problem is that the API uses SOAP. Ruby has basically dropped SOAP in favor of REST. They provide a Java adapter that apparently works with the Java-Ruby bridge, but we'd like to keep it all in Ruby, if possible. I looked into soap4r, but it seems to have a slightly bad reputation.

So what's the best way to integrate SOAP calls into a Rails app?

+4  A: 

Try SOAP4R

And I just heard about this on the Rails Envy Podcast (ep 31):

Jason Navarrete
+10  A: 

We used the built in soap/wsdlDriver class, which is actually SOAP4R. It's dog slow, but really simple. The SOAP4R that you get from gems/etc is just an updated version of the same thing.

Example code:

require 'soap/wsdlDriver'

client = SOAP::WSDLDriverFactory.new( 'http://site.com/service.wsdl' ).create_rpc_driver
result = client.doStuff();

That's about it

Orion Edwards
Part of the reason why this is "Dog Slow" is that you are building the proxy every time you connect to the service. You could avoid this pain by using wsdl2ruby to build the proxy permanently and then call the pre-generated proxy.
Steve Weet
+2  A: 

Kent Sibilev from Datanoise had also ported the Rails ActionWebService library to Rails 2.1 (and above). This allows you to expose your own Ruby-based SOAP services. He even has a scaffold/test mode which allows you to test your services using a browser.

Philippe Monnet
+5  A: 

We switched from Handsoap to Savon.

Here is a series of blog posts comparing the two client libraries.

phoet
+12  A: 

Not that I'm associated with this Ruby SOAP client library ;) but I would recommed to check out Savon: http://wiki.github.com/rubiii/savon and go Heavy metal!

rubiii
+1 for savon is really quick and easy!
Luke
+1 for savon, not to bash soap4r - but I had really bad experience with it. Lack of good documentation and too cumbersome.
Nick Gorbikoff
+1 for savon, using it without a problem
MatthewFord
+3  A: 

I also recommand Savon http://wiki.github.com/rubiii/savon. I spent too many hours trying to deal with Soap4R, without results. Big lack of functionnalitys, no doc ...

Savon is the answer fot me.

brunetton