views:

1197

answers:

5

I'm using Fedex's web services and getting an annoying error right up front before I can actually get anywhere.

There was an error in serializing body of message addressValidationRequest1: 'Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'FedEx.InterOp.AddressValidationServiceReference.ParsedElement[]' to 'FedEx.InterOp.AddressValidationServiceReference.ParsedElement' error CS0029: Cannot implicitly convert type 'FedEx.InterOp.AddressValidationServiceReference.ParsedElement' to 'FedEx.InterOp.AddressValidationServiceReference.ParsedElement[]' '. Please see InnerException for more details.

I'm using .NET 3.5 and get a horrible named class generated for me (I'm not sure why it isn't just AddressValidationService):

AddressValidationPortTypeClient addressValidationService = new ...;

on this class I make my web service call:

addressValidationService.addressValidation(request);

This is when I get this error.

The only references I can find to this error come from ancient 1.1 projects. In my case my DLL has references to System.Web and System.Web.Services which seemed to be an issue back then.

+1  A: 

Turns out Fedex's own documentation covers this specifically!

I am using wsdl.exe from Microsoft to generate code and I get an error CS0029: Cannot implicitly convert type 'fedexreq.ParsedElement' to 'fedexreq.ParsedElement[]'.

This is an error generated by Web Services Description Language Tool (Wsdl.exe) to generate the client information. When you publish a schema that contains nested nodes that have the maxOccurs attribute set to the "unbounded" value, the Wsdl.exe tool creates multidimensional arrays in the generated code file. Therefore, the generated code contains incorrect types for the nested nodes. To solve modify the generated code by removing the bracket ([]) array characters from the data type delectation statements. For more information see http://support.microsoft.com/kb/326790/en-us and http://support.microsoft.com/kb/891386

Simon_Weaver
A: 

But where in the code we need to make these changes ? I can't solve this problem.

added answer below
Simon_Weaver
A: 

You only need change the [][], not the single [].

In Reference.cs change

private ParsedElement[][] parsedStreetLineField;
to
private ParsedElement[] parsedStreetLineField;
and
public ParsedElement[][] ParsedStreetLine {
to
public ParsedElement[] ParsedStreetLine {
Simon_Weaver
A: 

Thanks a lot. That fixed my issue. (Reference.cs)

Ashok