Listing 1

<?xml version="1.0" encoding="UTF-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://webservices.amazon.com/AWSECommerceService/2007-04-04"
  targetNamespace="http://webservices.amazon.com/AWSECommerceService/2007-04-04">
- <binding name="AWSECommerceServiceBinding" type="tns:AWSECommerceServicePortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="Help">
  <soap:operation soapAction="http://soap.amazon.com" />
- <input>
  <soap:body use="literal" />
  </input>

Listing 2

call sa_make_object( 'function', 'ItemLookup');
alter function ItemLookup(SubscriptionId char(40), IdType char(10), ItemId char(13), ResponseGroup char(10)  )
    RETURNS LONG VARCHAR
    url 'http://soap.amazon.com/onca/soap?Service=AWSECommerceService'
    namespace 'http://webservices.amazon.com/AWSECommerceService/2007-04-04'
    type 'SOAP:DOC'
;

Listing 3

call sa_make_object('procedure', 'ItemLookupWrapper');
alter procedure ItemLookupWrapper(@UPC char(13))
begin
INSERT INTO Media(ItemID, Title, Manufacturer, Author)
SELECT @UPC , Title, Manufacturer, Author
FROM openxml( ItemLookup('[your access key here]', 'ASIN', @UPC, 'Small'), '//*:ItemAttributes' )
WITH ("Title"        long varchar  '*:Title/text()',
      "Manufacturer" long varchar  '*:Manufacturer/text()',
      "Author" long varchar  '*:Author/text()'
    );
SELECT * FROM Media WHERE ItemID = @UPC;
end;

delete from media;
call ItemLookupWrapper('0761543627');

Listing 4

HTTP/1.1 200 OK
Date: Thu, 03 May 2007 14:23:16 GMT
Server: Server
x-amz-id-1: 00GQP9NPCXZ4J1CP2HW6
x-amz-id-2: ydnV1ELebKkA7cdMk7BaFPVgyXkh6SDPT4a2KvvzZD0=
Connection: close
Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <SOAP-ENV:Body>
    <ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2007-04-04">
      <OperationRequest>
        <HTTPHeaders>
          <Header Name="UserAgent" Value="SQLAnywhere/10.0.0.2465"></Header>
        </HTTPHeaders>
        <RequestId>00GQP9NPCXZ4J1CP2HW6</RequestId>
        <Arguments>
          <Argument Name="Service" Value="AWSECommerceService"></Argument>
        </Arguments>
        <RequestProcessingTime>0.0221960544586182</RequestProcessingTime>
      </OperationRequest>
      <Items>
        <Request>
          <IsValid>True</IsValid>
        </Request>
        <Item>
          <ASIN>0761543627</ASIN>

<DetailPageURL>http://www.amazon.com/gp/redirect.html%3FASIN=0761543627%26tag=ws%26lcode=sp1%26cID=2025%26ccmID=165
953%26location=/o/ASIN/0761543627%253FSubscriptionId=[your acces key here]</DetailPageURL>
          <ItemAttributes>
            <Author>David Hodgson</Author>
            <Manufacturer>Prima Games</Manufacturer>
            <ProductGroup>Book</ProductGroup>
            <Title>Half-Life 2 (PC) (Prima Official Game Guide)</Title>
          </ItemAttributes>
        </Item>
      </Items>
    </ItemLookupResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Listing 5

// Profile Amazon
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=Amazon;UID=DBA;PWD=sql'"

CONNECT USING SQLCA;
If SQLCA.SQLCode <> 0 Then
	MessageBox('', 'Error connecting to database')
End If


Open(w_main)