Newbie: Getting Book Data from Amazon


#1

As part of my inaugural Ruby project, I’ve been trying to get data
for books from Amazon’s web services. The first thing I tried was
Ruby/Amazon http://www.caliban.org/ruby/ruby-amazon.shtml. It works
great, but is based on an earlier version of Amazon’s Web Services,
which apparently doesn’t return a complete set of data for the items
it retrieves. (The one missing piece that I really need is the number
of pages in a book.)

So, next up, I’m trying to get the hang of using soap4r. That library
comes with some sample code for Amazon’s E-Commerce Web Services. If
I understand correctly, the way it works is to use WSDL to build an
RPC driver with methods defined on the fly by the WSDL, something
like this:

drv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver

This seems to work great – I get a fully populated drv object with
all the methods and stuff from the WSDL descriptor, according to
drv.methods. The problem, however, is that I’m having a hard time
figuring out what parameters to feed to the ItemSearch method, which
is what I really want to use. (I suspect that Ruby’s reflection
methods might be able to tell me, but I’ve not figured out the syntax
to get it to tell me what parameters a method is expecting.)

The sample code that comes with soap4r /sample/wsdl/amazonEC/
client.rb looks promising, but is untested since the developer
doesn’t have an account with Amazon, and doesn’t appear to work as-is.

So, my questions, in descending order of helpfulness:

  • Does anybody have a working sample of using soap4r to access
    Amazon’s e-commerce services?
  • Is there a way to see what parameters a dynamically generated
    method expects?
  • Any other helpful advice?

Thanks in advance for any help!

Sean