It is simple to use a web service in Ruby using the SOAP RPC Driver in the Ruby standard library. The following example is based on the Ruby Cookbook (Recipe 16.4 Writing a SOAP Client), and works well with web services created by Apache Axis. The free web service from BookPrice.com calculates an ISBN-13 or EAN from an old ISBN-10:

require 'soap/rpc/driver'
url = 'http://www.booksprice.com/IsbnConverter.jws'
urn = 'http://www.booksprice.com/IsbnConverter.jws'
service = SOAP::RPC::Driver.new(url,urn)
service.add_method('convertToISBN13','isbn10')
puts service.convertToISBN13("1400063515")
>> 978-1-400063-51-2

..just open a ruby console and check it yourself. One can also call other functions of the same web service in the same way (the example ISBN belongs to the Black Swan book):

service.add_method('convertToEAN','isbn10')
puts service.convertToEAN("1400063515")
>> 9781400063512
Advertisements