What's the best way to use SOAP with Ruby?

Viewed 87574

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?

10 Answers

I built Savon to make interacting with SOAP webservices via Ruby as easy as possible.
I'd recommend you check it out.

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://example.com/service.wsdl' ).create_rpc_driver
result = client.doStuff();

That's about it

We switched from Handsoap to Savon.

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

I also recommend Savon. I spent too many hours trying to deal with Soap4R, without results. Big lack of functionality, no doc.

Savon is the answer for me.

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.

Related