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
Hi,
I just discovered your blog – you have a lot of interesting and relevent posts (and to the point – I like that).
In this example, I just have one question:
What is isbn10 in this context – and how do you know what to put there?
Thanks for a great blog
/vesters
Ah – just found out.
The problem was that firefox did’nt pick it up when I did a search on the phrase:-)