Developer Resources’s Weblog

June 9, 2008

Ruby SOAP Client

Filed under: Examples, Ruby, Web Services — Tags: , , , — developerresources @ 8:20 am

Here is an example of how to call a web service using Ruby. This example requires no external libraries, everything is built into the language. However it does require version 1.8.5 early version don’t have the create_rpc_driver method.



#Requires Ruby version 1.8.5 or highet
require 'soap/wsdlDriver'
require 'pp'
wsdl = 'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver

# Log SOAP request and response
driver.wiredump_file_base = "soap-log.txt"

response =  driver.IsValidISBN13(:sISBN => '0000000000000')
#pp(response)
puts response.isValidISBN13Result

For more information about Ruby and Web Services I recommend Ruby Cookbook (Cookbooks (O’Reilly)).

2 Comments »

  1. I am searching for last 3 weeks for a working model of Ruby client in web services. This is the only one I could find works. It would be greatly appreciated if you post how to create a server in Ruby too. And also a little bit of explanation for your client too

    Comment by raghu — June 18, 2008 @ 5:26 pm

  2. It is also possible to build a Ruby client for web services by using the SOAP RPC Driver, as I described here:

    http://4loc.wordpress.com/2008/11/18/using-web-services-in-ruby/

    Comment by GreenAlgae — August 26, 2009 @ 8:14 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.