使用Asp.net的Amazon Book Search API
发布时间:2020-12-16 03:20:10 所属栏目:asp.Net 来源:网络整理
导读:如何使用amazon API在asp.net上使用ISBN号搜索图书? 解决方法 http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl 使用svcutil.exe为上面给出的URL创建代理 然后这是GetBookByISBN的方法. AmazonBook是我必须创建自己的cutom DTO
如何使用amazon API在asp.net上使用ISBN号搜索图书?
解决方法
http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl
使用svcutil.exe为上面给出的URL创建代理 然后这是GetBookByISBN的方法. AmazonBook是我必须创建自己的cutom DTO. 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 to the 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, (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – MVC2 Binding不适用于Html.DropDownListFor
- asp.net-mvc – 理解和使用“服务层” – .NET MVC 5
- asp.net-mvc – 在您的ViewModel中放置什么
- asp.net – asp文本框控件的CSS
- asp.net-web-api – 用于自托管模式的WebApi按请求存储
- asp.net-mvc – RavenDB Ids和ASP.NET MVC3路由
- asp.net – 如何让我的转发器的Itemcommand事件不进行整页回
- Asp.net对Php性能
- asp.net-mvc – 带Postgres的ASP.NET MVC; ORM建议?
- ViewState在ASP.NET MVC中是否相关?
推荐文章
站长推荐
- asp.net – Request.IsAuthenticated总是如此.我
- asp.net-mvc – ViewBag.Title值覆盖ASP.NET MVC
- asp.net – 访问视图Mvc.net中的路由值
- asp.net-mvc – 在多租户应用程序中使用多个数据
- asp.net-mvc – 什么是Razor中的ViewBag.Title?
- asp-classic – 用于ASP的“Dim”是什么?
- asp.net – 使用asp:GridView进行分页时是否需要
- Asp.net中的Session和Cookie
- asp.net-mvc – Asp.net MVC – 我可以从不同的视
- ASP.NET版CKEditor与CKFinder的配置使用
热点阅读