Background

I want to integration with the Amazon Associates (nee ECS) web service. There are several gems available for doing this, but their functionality is limited and their documentation sucks. Amazon publishes a WSDL descriptor for their SOAP interface, so let’s see if we can roll our own.

Resources

http://crastinate.jonwiley.com/?p=15

http://www.brendonwilson.com/blog/2006/04/02/ruby-soap4r-wsdl-hell/

Preparation

  1. gem install soap4r
  2. wsdl2ruby.rb –wsdl http://ecs.amazonaws.com/AWSECommerceService/2007-10-29/AWSECommerceService.wsdl –type client –module_path Amazon

Code

require 'rubygems'
gem 'soap4r'
require 'defaultDriver.rb'

request = ItemLookupRequest.new
request.itemId = ["B00005JLXH"]
body = ItemLookup.new
body.aWSAccessKeyId = <YOUR AWS ID>
body.request = request

obj = AWSECommerceServicePortType.new()
response = obj.itemLookup(body)

puts response.items[0].item[0].itemAttributes.title

Rock.