mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
42bca643c3
* lib/soap/encodingstyle/soapHandler.rb, lib/soap/mapping/factory.rb, lib/soap/mapping/mapping.rb, lib/soap/mapping/registry.rb, lib/wsdl/soap/complexType.rb: ApacheSOAP's map support was broken under WSDL dynanic client environment. fixed. * test/wsdl/raa/*: add tests. * lib/xsd/datatypes.rb: dateTime precision bug fix (at least, I hope.) bug of soap4r. XSDDateTimeImple.to_time passed a Float to Time.local/Time.gm as an usec, and NUM2LONG(rb_num2long for Float) causes rounding error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
52 lines
1.6 KiB
Ruby
52 lines
1.6 KiB
Ruby
require 'soap/wsdlDriver'
|
|
|
|
book = ARGV.shift || "Ruby"
|
|
|
|
# AmazonSearch.rb is generated from WSDL.
|
|
# Run "wsdl2ruby.rb --wsdl http://soap.amazon.com/schemas3/AmazonWebServices.wsdl --classdef --force"
|
|
# http://soap.amazon.com/schemas3/AmazonWebServices.wsdl
|
|
require 'AmazonSearch.rb'
|
|
|
|
=begin
|
|
Or, define the class by yourself like this.
|
|
|
|
class KeywordRequest
|
|
def initialize(keyword = nil,
|
|
page = nil,
|
|
mode = nil,
|
|
tag = nil,
|
|
type = nil,
|
|
devtag = nil,
|
|
sort = nil)
|
|
@keyword = keyword
|
|
@page = page
|
|
@mode = mode
|
|
@tag = tag
|
|
@type = type
|
|
@devtag = devtag
|
|
@sort = sort
|
|
end
|
|
end
|
|
=end
|
|
|
|
# You must get 'developer's token" from http://associates.amazon.com/exec/panama/associates/ntg/browse/-/1067662 to use Amazon Web Services 2.0.
|
|
#devtag = File.open(File.expand_path("~/.amazon_key")) { |f| f.read }.chomp
|
|
devtag = nil
|
|
|
|
# v2: AMAZON_WSDL = 'http://soap.amazon.com/schemas2/AmazonWebServices.wsdl'
|
|
AMAZON_WSDL = 'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl'
|
|
amazon = SOAP::WSDLDriverFactory.new(AMAZON_WSDL).create_driver
|
|
p "WSDL loaded"
|
|
amazon.generate_explicit_type = true
|
|
amazon.mandatorycharset = 'utf-8' # AWS should fix this bug.
|
|
#amazon.wiredump_dev = STDERR
|
|
|
|
# Show sales rank.
|
|
req = KeywordRequest.new(book, "1", "books", "webservices-20", "lite", devtag, "+salesrank")
|
|
amazon.KeywordSearchRequest(req).Details.each do |detail|
|
|
puts "== #{detail.ProductName}"
|
|
puts "Author: #{detail.Authors.join(", ")}"
|
|
puts "Release date: #{detail.ReleaseDate}"
|
|
puts "List price: #{detail.ListPrice}, our price: #{detail.OurPrice}"
|
|
puts
|
|
end
|