Re: Using Amazon's WSDL services



Although Amazon::Search works, I'd love to see an example that actually
uses Soap4r and doesn't just do the HTTP requests itself.

j.


On 11/29/05, Dave Baldwin <dave.baldwin@xxxxxxxxxx> wrote:
>
>
> On 29 Nov 2005, at 13:57, H. Wade Minter wrote:
>
> > I'm trying to create a simple test script to hit Amazon's web
> > services via
> > their WSDL listing (specifically the Wishlist Lookup). I'm going
> > on the
> > examples in the Pickaxe.
> >
> > Here's my sample script:
> >
> > #####
> > #!/usr/bin/env ruby
> >
> > require 'soap/wsdlDriver'
> >
> > wsdl = 'http://webservices.amazon.com/AWSECommerceService/
> > AWSECommerceService.wsdl'
> >
> > soap = SOAP::WSDLDriverFactory.new(wsdl).createDriver
> >
> > result = soap.ListLookup
> > #####
> >
> > However, when I run it, I'm getting a ton of error messages to the
> > screen
> > that look like:
> >
> > Unknown element {http://www.w3.org/2001/XMLSchema}annotation.
> > Unknown attr {}ref.
> > Unknown attr {}ref.
> >
> > Followed by a final error like:
> >
> > soap.rb:10: undefined method `ListLookup' for #<SOAP::WSDLDriver:
> > 0x84f7898>
> > (NoMethodError)
> >
> > I'm not a WSDL expert, so I'm confused as to whether the problem is
> > on my
> > end, or on the Amazon end. Anyone better-versed than I willing to
> > take a
> > look?
> >
> > Thanks,
> > Wade
>
> Try using the ruby amazon library
> http://www.caliban.org/ruby/ruby-amazon.shtml
>
> makes this type of thing so easy. I used it to pull album art:
>
>
> require 'open-uri.rb'
> require 'amazon/search'
> include Amazon
>
> DEV_TOKEN = "XXXXXXXXXXXXXXXX" # you need to register to get
> one of these
>
> def getArtwork (artist, album)
> image = nil
> re = Regexp.new(album, Regexp::IGNORECASE)
> print "Looking for #{artist}, #{album} ..."
> req = Search::Request.new(DEV_TOKEN, nil, 'uk')
> resp = req.artist_search(artist, 'music', Search::LITE)
> prods = resp.products
> pr = prods.find {|pr| pr.product_name =~ re}
> if pr
> image = open(pr.image_url_small).read
> print "got artwork\n"
> else
> print " not found.\n Possible album names:"
> prods.each {|pr| puts "\t#{pr.product_name}"}
> end
> sleep 1 # don't access amazon too quickly
> image
> end
>
> Dave.
>
> >
>
>
>


--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org";

Jeff Wood