Error CS0030: Unable to convert the type “Simple.Amazon.ECS.ImageSet []” to “Simple.Amazon.ECS.ImageSet" in the Amazon web service

I am trying to make a small application that can search a book in Amazon on ISBN. I am completely new to Amazon web service.

The links are listed below:

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

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

Find an Amazon example with the 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 a request, I get this exception

An error occurred in serializing the body of the message ItemSearchRequest1: 'Unable to create a temporary class (result = 1).

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

Internal exception:

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

I do not understand why I get this. What am I doing wrong?

+7
c # amazon wcf amazon-product-api
source share
1 answer

This is usually an error in generating a WCF proxy. See here for some details and a workaround.

Taken from the link for comments :

These are the steps from January 31, 2012 to fix this problem in Visual Studio for .Net clients:

1) Click the "Show all files" button in the solution explorer for the project containing a link to the amazon service.

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

3) On line 584, change the value of "maxOccurs" to "1".

4) Save the AWSECommerceService.wsdl file

5) Right-click the Reference.svcmap link and select "Run Custom Tool"

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

7) Go to the AmazonAPI.your namespace. Use the drop down menu at the top of the window.

8) Go to the ImageSets property and confirm that its declaration is as follows:

 public ImageSet[] ImageSets { 

and do not like

 public ImageSet[][] ImageSets { 

9) Rebuild your project

+11
source share

All Articles