Я пытаюсь использовать новый продукт Amazon API для поиска продуктов на Amazon. Я смотрел на их примеры кода и примеры других людей, но я не получаю никаких результатов и не задаюсь вопросом, использовал ли кто -нибудь еще этот API и мог бы оказать некоторую помощь? < /p>
using System;
using System.ServiceModel;
using Simple.Amazon.ECS;
namespace Simple {
class Program {
// your Amazon ID's
private const string accessKeyId = "*******************";
private const string secretKey = "************************************";
// the program starts here
static void Main(string[] args) {
// create a WCF Amazon ECS client
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = int.MaxValue;
AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
binding,
new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
// add authentication to the ECS client
client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));
// prepare an ItemSearch request
ItemSearchRequest request = new ItemSearchRequest();
request.SearchIndex = "Books";
request.Title = "WCF";
request.ResponseGroup = new string[] { "Small" };
ItemSearch itemSearch = new ItemSearch();
itemSearch.Request = new ItemSearchRequest[] { request };
itemSearch.AWSAccessKeyId = accessKeyId;
// issue the ItemSearch request
ItemSearchResponse response = client.ItemSearch(itemSearch);
// write out the results
foreach (var item in response.Items[0].Item) {
Console.WriteLine(item.ItemAttributes.Title);
}
}
}
}
Все примеры/примеры похожи на этот по структуре, но когда дело доходит до цикла foreach, элементы не возвращаются (Null), поэтому я получаю нулевую ошибку исключения.
Я пытаюсь использовать новый продукт Amazon API для поиска продуктов на Amazon. Я смотрел на их примеры кода и примеры других людей, но я не получаю никаких результатов и не задаюсь вопросом, использовал ли кто -нибудь еще этот API и мог бы оказать некоторую помощь? < /p>
[code]using System; using System.ServiceModel; using Simple.Amazon.ECS;
namespace Simple { class Program { // your Amazon ID's private const string accessKeyId = "*******************"; private const string secretKey = "************************************";
// the program starts here static void Main(string[] args) {
// create a WCF Amazon ECS client BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
// add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));
// prepare an ItemSearch request ItemSearchRequest request = new ItemSearchRequest(); request.SearchIndex = "Books"; request.Title = "WCF"; request.ResponseGroup = new string[] { "Small" };
ItemSearch itemSearch = new ItemSearch(); itemSearch.Request = new ItemSearchRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId;
// issue the ItemSearch request ItemSearchResponse response = client.ItemSearch(itemSearch);
// write out the results foreach (var item in response.Items[0].Item) { Console.WriteLine(item.ItemAttributes.Title); } } } } [/code]
Все примеры/примеры похожи на этот по структуре, но когда дело доходит до цикла foreach, элементы не возвращаются (Null), поэтому я получаю нулевую ошибку исключения.