最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】已装AWS SDK for .NET,但是C#中找不到AWSECommerceService和ItemLookup

Amazon crifan 3603浏览 0评论

【问题】

折腾:

【记录】尝试使用AWS SDK for .NET去实现C#版本的ItemLookup

期间,在AWS Console Project中,想要实现ItemLookup,然后去参考别人代码:

amazon product advertising api – item lookup request working example

getAmazonSearchResults

但是发现C#中找不到AWSECommerceService和ItemLookup这些类。

虽然已经加了:

using Amazon;
using Amazon.EC2;
using Amazon.EC2.Model;
using Amazon.SimpleDB;
using Amazon.SimpleDB.Model;
using Amazon.S3;
using Amazon.S3.Model;

using Amazon.AWSSupport;

但是还是找不到:

can not find AWSECommerceService

【解决过程】

1.别人:

Amazon AWS web service

也是用的这 个AWSECommerceService

2.后来也在api中,看到一个类似的AmazonWebServiceClient:

AmazonWebServiceClient and AWSCredentials

不知道是否可用。

3.这里:

"Hello Amazon!" – Making a first request to the Amazon Product API

提到了,好像需要把

http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

加入到对应的Service Reference中的。

所以去试试:

reference add service reference

add service reference url then ok

然后,没有找到AWSECommerceService,但是却的确找到了之前就看到别人:

C# search amazon example with new amazon service

用的另外一个:

AWSECommerceServicePortTypeClient

found AWSECommerceServicePortTypeClient

另外,也找到了对应的ItemLookup和ItemSearch

find itemlookup and itemsearch

至此,后续就可以参考去写代码了。

3.但是却发现,结果代码中,还是找不到AWSECommerceServicePortTypeClient,ItemLookup:

still can not find AWSECommerceServicePortTypeClient

4.干脆去下载:

"Hello Amazon!" – Making a first request to the Amazon Product API

中的示例代码:

amazonecsdemo.zip

然后看了看,其是:

his is member of demo

can find ItemSearchRequest

然后我此处,也确认是类似的:

my here is Member of AwsConsoleApp1

but also can not found AWSECommerceServicePortTypeClient

但是还是找不到,所以,放弃了。

4.估计是此处的,console的项目,而不是人家的Form项目。

所以,去找个Form的项目去试试。

dotnet 4 winform project

然后经过折腾,才明白,到底是如何使用的:

(1)此处项目名是:

AwsWinformApiDemo

(2)正常的添加服务引用:

Add Service Reference -> http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

其中对应的文件夹是AWSECommerceService:

url then namespace then ok

(3)确认一下,AWSECommerceService所对应的api的关系是,在你的项目之下的:

AWSECommerceService api in under your project

(4)使用各种AWSECommerceService的类和属性之前,需要添加对应的引用using:

using 项目名.AWSECommerceService

此处即:

using AwsWinformApiDemo.AWSECommerceService;

然后再引用AWSECommerceService中的各个属性,类,函数等等,就可以了:

即AWSECommerceServicePortTypeClient,ItemLookup,ItemLookupRequest等等:

then can use AWSECommerceServicePortTypeClient

 

【总结】

1.貌似现在,2012-06-13,已经没有了那个AWSECommerceService,变成了新的AWSECommerceServicePortTypeClient

2.想要在C#项目中使用AWSECommerceService中的各种属性和类(AWSECommerceServicePortTypeClient,ItemLookup,ItemLookupRequest等等),需要:

(1)添加AWSECommerceService的Service Reference:

References -> Add Service Reference ->

Address:http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

Namespace:AWSECommerceService

(2)代码中添加using:

using YourProjectNamespace.AWSECommerceService;

(3)然后就可以在代码中使用各种类,各种成员了,包括:AWSECommerceServicePortTypeClient,ItemLookup,ItemSearch等等:

AWSECommerceServicePortTypeClient ecs = new AWSECommerceServicePortTypeClient();
ItemLookup lookup = new ItemLookup();
ItemLookupRequest request = new ItemLookupRequest();

转载请注明:在路上 » 【已解决】已装AWS SDK for .NET,但是C#中找不到AWSECommerceService和ItemLookup

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.183 seconds, using 22.12MB memory