i am trying to search in amazon product database with the following code posted in amazon webservice sample codes page
AWSECommerceService ecs = new AWSECommerceService();
// Create ItemSearch wrapper
ItemSearch search = new ItemSearch();
search.AssociateTag = "ABC";
search.AWSAccessKeyId = "XYZ";
// Create a request object
ItemSearchRequest request = new ItemSearchRequest();
// Fill request object with request parameters
request.ResponseGroup = new string[] { "ItemAttributes" };
// Set SearchIndex and Keywords
request.SearchIndex = "All";
request.Keywords = "The Shawshank Redemption";
// Set the request on the search wrapper
search.Request = new ItemSearchRequest[] { request };
try
{
//Send the request and store the response
//in response
ItemSearchResponse response = ecs.ItemSearch(search);
gvRes.DataSource = response.Items;
}
catch (Exception ex)
{
divContent.InnerText = ex.Message;
}
and getting the following error
The request must contain the parameter Signature.
and amazon documentation is not clear about how to sign the requests.
any idea how to make it work???
thx
There's a helper class for REST called SignedRequestHelper.
You call it like so:
There must be a similar one for SOAP calls in the above links.
try this one.. i hope it'll help.. i try and it works.. please share it with others.
download the sample code on http://www.falconwebtech.com/post/Using-WCF-and-SOAP-to-Send-Amazon-Product-Advertising-API-Signed-Requests
we need to update service references, make little change at app.config, program.cs, and reference.cs.
app.config: (1.) appSettings tag; assign accessKeyId and secretKey value, add . (2.) behaviours tag -> endpointBehaviors tag -> behaviour tag -> signingBehavior tag; assign accessKeyId and secretKey value. (3.) bindings tag -> basicHttpBinding tag; (optional) delete binding tag except AWSECommerceServiceBindingNoTransport and AWSECommerceServiceBindingTransport. (4.) client tag; delete endpoint tag except AWSECommerceServiceBindingTransport.
program.cs: add itemSearch.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; before ItemSearchResponse response = amazonClient.ItemSearch(itemSearch);
reference.cs: (open file in service references folder using visual studio) change private ImageSet[][] imageSetsField; to private ImageSet[] imageSetsField; change public ImageSet[][] ImageSets {...} to public ImageSet[] ImageSets {...}
finally we can run our program and it will work. good luck..
nb: there will be 1 warning (invalid child element signing behaviour), i think we can ignore it, or if you have any solution please share.. ^^v..
i transcribed this vb code and it works for me
add the service reference and name it Amazon
go into the folder where your project is hosted, open the service reference folder and open the Reference.cs, then replace all the occurrences of [][] with [], next open AWSECommerceService.wsdl and find
and replace with
add the following, and you'll need to manually reference some dlls
first various interface implementations
now you use the generated code in this way