'Error serializing body'. Problem calling Fedex webservice through .NET 3.5

后端 未结 3 1548
日久生厌
日久生厌 2020-12-16 20:52

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 a

相关标签:
3条回答
  • 2020-12-16 21:38

    Note: To access the Reference.cs file that Simon_Weaver is referring to, open the project in visual studio, and in the Solution Explorer, click on the Web Reference and then look at the little icons at the top of Solution Explorer. Click the "Show All Files" icon to show hidden files. Now expand the web reference, then expand the Reference.map inside, and finally you will see Reference.cs which you can edit, replacing [][] with []

    Do not confuse this Reference.cs with the Reference.cs you may have obtained from Fedex when downloading their sample code.

    0 讨论(0)
  • 2020-12-16 21:46

    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

    0 讨论(0)
  • 2020-12-16 21:50

    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 {
    
    0 讨论(0)
提交回复
热议问题