c# - How better request Amazon Product Advertising API Web service? -
i use amazon product advertising api web service in mvc project. created simple c# console project test domain classes. default amazon product advertising api web service request can't return more 10 item per page, need display more 10 items in web page.
for create additional logic
namespace amazonproductadvertisingapi.console { class program { private const string accesskeyid = "####"; private const string secretkey = "####"; static void main(string[] args) { basichttpbinding binding = new basichttpbinding(basichttpsecuritymode.transport); binding.maxreceivedmessagesize = int.maxvalue; // create wcf amazon ecs client awsecommerceserviceporttypeclient client = new awsecommerceserviceporttypeclient( //new basichttpbinding(basichttpsecuritymode.transport), binding, new endpointaddress("https://webservices.amazon.com/onca/soap?service=awsecommerceservice")); // add authentication ecs client client.channelfactory.endpoint.behaviors.add(new amazonsigningendpointbehavior(accesskeyid, secretkey)); // prepare itemsearch request string searchindex = "books"; string title = "bible"; string[] responsegroup = new string[] { "small", "itemattributes" }; itemsearchrequest firstrequest = new itemsearchrequest(); firstrequest.searchindex = searchindex; firstrequest.title = title; firstrequest.responsegroup = responsegroup; firstrequest.itempage = "1"; itemsearch itemsearch = new itemsearch(); itemsearch.request = new itemsearchrequest[] { firstrequest }; itemsearch.awsaccesskeyid = accesskeyid; itemsearch.associatetag = "http://affiliate-program.amazon.com/"; itemsearchresponse firstresponse = client.itemsearch(itemsearch); foreach (var item in firstresponse.items[0].item) { system.console.writeline(item.itemattributes.title); } int totalpages = convert.toint32(firstresponse.items[0].totalpages); if (totalpages > 1) { (int = 2; < totalpages; i++) { awsecommerceserviceporttypeclient newclient = new awsecommerceserviceporttypeclient( //new basichttpbinding(basichttpsecuritymode.transport), binding, new endpointaddress("https://webservices.amazon.com/onca/soap?service=awsecommerceservice")); newclient.channelfactory.endpoint.behaviors.add(new amazonsigningendpointbehavior(accesskeyid, secretkey)); itemsearchrequest repeatedrequest = new itemsearchrequest() { searchindex = searchindex, title = title, responsegroup = responsegroup, itempage = convert.tostring(i) }; itemsearch ritemsearch = new itemsearch(); ritemsearch.request = new itemsearchrequest[] { repeatedrequest }; ritemsearch.awsaccesskeyid = accesskeyid; ritemsearch.associatetag = "http://affiliate-program.amazon.com/"; itemsearchresponse repeatedresponse = newclient.itemsearch(ritemsearch); foreach (var item in repeatedresponse.items[0].item) { system.console.writeline(item.itemattributes.title); } } } } } }
return me:
an unhandled exception of type 'system.servicemodel.servertoobusyexception' occurred in mscorlib.dll additional information: http service located @ https://webservices.amazon.com/onca/soap?service=awsecommerceservice unavailable. because service busy or because no endpoint found listening @ specified address. please ensure address correct , try accessing service again later.
could , provide advice?
Comments
Post a Comment