Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Error serializing body'. Problem calling Fedex webservice through .NET 3.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.

like image 991
Simon_Weaver Avatar asked Dec 05 '08 22:12

Simon_Weaver


1 Answers

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

like image 53
Simon_Weaver Avatar answered Oct 07 '22 03:10

Simon_Weaver