Amazon Query

To be fair, Amazon does have their own native SOAP interface which most likely is a better option than this gateway. Please visit Amazon.com Web Services Homepage for more details. However, as an example on how to implement a Web service using SOAP::Lite, this might be just what you are looking for!

Amazon.com makes its product listings available through a REST interface. REST is an XML query protocol built entirely upon the HTTP request-response model. It uses query strings to pass arguments to the XML service. While I have no issues with a REST interface, I personally find it easier to use standard SOAP toolkits like SOAP::Lite to query Web services. These SOAP toolkits typically have XML parsing built-in, which makes it a little easier (IMHO) to traverse the response from the service.

That is why I built a SOAP gateway service to Amazon's REST interface. It is actually a very simple service (download the source below). All it does it unwrap a SOAP request with parameters passed in through the SOAP Body, compose an HTTP request with the corresponding URL, and return the response in a SOAP Envelope.

This service is available through the GNU Public License.

Resources

Source

  • Web Service
  • Web Service (MIME variant) - this one returns the results in a MIME attachment
  • WSDL
  • SOAP::Lite client (example)
  • Examples

    Example Search Request:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope 
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <SOAP-ENV:Body>
        <namesp1:query xmlns:namesp1="urn:AmazonQuery">
          <associates_id xsi:type="xsd:string">majordojo-20</associates_id>
          <product_group xsi:type="xsd:string">books</product>
    
          <keywords xsi:type="xsd:string">bar</keywords>
        </namesp1:query>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Example Browse Request:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope 
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <SOAP-ENV:Body>
        <namesp1:query xmlns:namesp1="urn:AmazonQuery">
          <associates_id xsi:type="xsd:string">majordojo-20</associates_id>
          <product_group xsi:type="xsd:string">books</product>
    
          <category xsi:type="xsd:string">foo</category>
        </namesp1:query>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    No Comments

    Leave a comment

    what will you say?


    Close