json - Amazon Book Search API using Asp.net -
how can amazon api used search book using isbn number asp.net?
http://webservices.amazon.com/awsecommerceservice/awsecommerceservice.wsdl create proxy using svcutil.exe above given url , method getbookbyisbn. amazonbook cutom dto have create own.
public static amazonbook getbookbyisbn(string isbn) { webconfighelper wch = new webconfighelper("awssettings"); amazonbook book = null; string awsaccesskeyid = wch["accesskey"]; string associatetag = wch["associatetag"]; string awsseckey = wch["secretkey"]; 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 ecs client client.channelfactory.endpoint.behaviors.add(new amazonsigningendpointbehavior(awsaccesskeyid, awsseckey)); itemsearchrequest request = new itemsearchrequest(); request.searchindex = "books"; request.power = "isbn:" + isbn.trim(); request.responsegroup = new string[] { "large" }; request.sort = "salesrank"; itemsearchrequest[] requests = new itemsearchrequest[] { request }; itemsearch itemsearch = new itemsearch(); itemsearch.awsaccesskeyid = awsaccesskeyid; itemsearch.associatetag = associatetag; itemsearch.request = requests; try { itemsearchresponse response = client.itemsearch(itemsearch); items info = response.items[0]; if (info.item != null) { item[] items = info.item; if (items.length == 1) { book = new amazonbook(items[0]); } } } catch (exception ex) { throw ex; } return book; }
reagards,
Comments
Post a Comment