Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error CS0030: Cannot convert type 'Simple.Amazon.ECS.ImageSet[]' to 'Simple.Amazon.ECS.ImageSet' in Amazon Web Service

I Am trying to make a small application which can search a book in amazon by it`s ISBN. I am completely new in Amazon Web Service.

I am following below links :

http://flyingpies.wordpress.com/2009/08/01/17/

http://flyingpies.wordpress.com/2009/08/13/signing-amazon-product-advertising-api-cwcf-part-2/

Search amazon example with new amazon service

And My Code Is :

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = int.MaxValue;

AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
    binding, new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AccessKeyId, SecretAccessKey));

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

request.IdType = ItemLookupRequestIdType.ISBN;
request.ItemId = new[] {"9780297870470"};
request.ResponseGroup = new[] { "OfferSummary" };
request.SearchIndex = "All";
request.IdTypeSpecified = true;

lookup.Request = new ItemLookupRequest[] { request };
lookup.AWSAccessKeyId = AccessKeyId;
lookup.AssociateTag = "wwwyaodaromane-90";
var response = amazonClient.ItemLookup(lookup);

When I try to Send Request I get this exception

There was an error in serializing body of message ItemSearchRequest1: 'Unable to generate a temporary class (result=1).

error CS0030: Cannot convert type 'Simple.Amazon.ECS.ImageSet[]' to 'Simple.Amazon.ECS.ImageSet'

Inner Exception Is :

{"Unable to generate a temporary class (result=1).\r\nerror CS0030: Cannot convert type 'Simple.Amazon.ECS.ImageSet[]' to 'Simple.Amazon.ECS.ImageSet'\r\nerror CS0029: Cannot implicitly convert type 'Simple.Amazon.ECS.ImageSet' to 'Simple.Amazon.ECS.ImageSet[]'\r\n"}

I don`t understand why I'm getting this. What I am doing wrong?

like image 386
Hasanuzzaman Avatar asked Sep 09 '13 13:09

Hasanuzzaman


1 Answers

This is usually a bug in the WCF proxy generation. See here for some details and a workaround.

Taken from comment link:

These are the steps as of January 31, 2012 to fix this issue in Visual Studio for .Net clients:

1) Click the "Show all files" button in the Solution Explorer for the project containing the amazon service reference.

2) Expand the reference and open the AWSECommerceService.wsdl file in the editor

3) On line 584 change the "maxOccurs' to "1".

4) Save the AWSECommerceService.wsdl file

5) Right click Reference.svcmap and click "Run custom tool"

6) Expand Reference.svcmap and open either Reference.cs or Reference.vb

7) Navigate to AmazonAPI.your namespace.Item using the drop down at the top of the window.

8) Navigate to the ImageSets property and confirm that its declaration looks like this:

public ImageSet[] ImageSets {

and NOT like this

public ImageSet[][] ImageSets {

9) Rebuild your project

like image 101
Yaron Naveh Avatar answered Oct 16 '22 06:10

Yaron Naveh