Fedex service integration error (could not create a temporary class)

I am trying to integrate Fedex Service into my asp.net website . I downloaded the code from the Fedex website, but when I run this simple program, I get an error message, Check the following code:

static void Main(string[] args) { TrackRequest request = CreateTrackRequest(); TrackService service = new TrackService();//I get Error Here if (usePropertyFile()) { service.Url = getProperty("endpoint"); } try { // Call the Track web service passing in a TrackRequest and returning a TrackReply TrackReply reply = service.track(request); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { ShowTrackReply(reply); } ShowNotifications(reply); } catch (SoapException e) { Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to quit!"); Console.ReadKey(); } 

The following debugging error occurred in TrackService service = new TrackService(); (line # 5):

Unable to create a temporary class (result = 1). Error CS0029: Unable to implicitly convert type 'TrackWebServiceClient.TrackServiceWebReference.EMailNotificationEventType' to 'TrackWebServiceClient.TrackServiceWebReference.EMailNotificationEventType []'

+6
source share
2 answers

This may be a problem with the way WSDL.exe generates client code.

You will need to manually edit the Reference.cs file to replace the double brackets [][] with one definition [] in EmailNotificationEventType .

From Microsoft :

There is currently no permission. However, three workarounds are available:

  • You can create a proxy class manually using WSDL.exe, and then change the proxy class in which the data type was incorrectly created as a two-dimensional array (for example, "CustomType [] []") so that it is a one-dimensional array (for example, " CustomType [] ").
  • You can change the data type in the required Web Services Description Language (WSDL) so that a second, optional element is included in the definition. You can do this by adding the following element: <xs:element minOccurs="0" name="dummyElement" nillable="true" type="xs:string"/>
  • You can change the complex type in the desired WSDL so that the boundary attributes are part of the complex type and not part of the element. (That is, you can move the minOccurs and maxOccurs attributes to a complex type, and then remove them from the element.)

Check also this link for further explanation.

+16
source

I tried the third option "You can change the complex type in the desired WSDL so that the boundary attributes are part of the complex type and not part of the element. (That is, you can move the minOccurs and maxOccurs attributes to the complex type and then remove them from the element.) "And it worked. The solution is below:

Removed from WSDL minOccurs and maxOccurs for the NotificationEventsAvailable element [see image below]

Click to see image.

0
source

Source: https://habr.com/ru/post/971104/


All Articles