Introduction
This article is a simple "Hello"-type program to instantiate and interpret a simple request to the Amazon ECommerce Services.
Background
In order to make a request, you simply must supply your own AWSAccessKeyID. You can get one for free at http://aws.amazon.com/.
Amazon does supply some code to perform a similar test at
http://docs.amazonwebservices.com/AWSECommerceService/2009-01-06/GSG/index.html?ImplementinganA2SRequest.html,
but it doesn't compile as is, and doesn't show the nice features available for using the information in the response without having to process the raw XML.
Using the code
In order to make use of the product API, you need to add it as a service
reference to your project. In Solution Explorer, right-click on References and select "Add Service Reference...".
Use http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl as the address.
Add a using reference anyplace you want to access the full set of objects and methods in the service. Web Services are wonderful - two steps, and you can use intellisense
to sort through the functionality.
To get information from the API, you need to first create a request. That request is attached to a search which
is just a wrapper for one or more searches that also holds the AWSAccessKeyID
. Finally, a port is opened and an ItemSearch
is invoked with the search as a parameter.
ItemSearchRequest request = new ItemSearchRequest();
request.ResponseGroup = new string[] { "ItemAttributes" };
request.SearchIndex = "All";
request.Keywords = txtLookupEAN.Text;
ItemSearch search = new ItemSearch();
search.AWSAccessKeyId = "[INSERT YOUR ACCESS ID HERE]";
search.Request = new ItemSearchRequest[] { request };
AWSECommerceServicePortTypeClient port =
new AWSECommerceServicePortTypeClient();
ItemSearchResponse response = port.ItemSearch(search);
Points of Interest
One small difficulty in searching for information is that while Amazon continues to rename the technology for ECommerce Services,
the original name is still in widespread use. Originally, it was called ECS (ECommerce Services), then it was named "Amazon Associates
Web Service", and now it is officially "Product Advertising API". However, the base WSDL document is still named AWSECommerceService.wsdl.
History
None so far.