I am trying to integrate Fedex Service in my asp.net website. I have downloaded the code from the Fedex website, but when I run this simple program I get an error, 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 error on debugging occurred on TrackService service = new TrackService();
(line #5):
Unable to generate a temporary class (result=1). error CS0029: Cannot implicitly convert type 'TrackWebServiceClient.TrackServiceWebReference.EMailNotificationEventType' to 'TrackWebServiceClient.TrackServiceWebReference.EMailNotificationEventType[]'
This might be an issue with the way that WSDL.exe generates the client code.
You will have to manually edit Reference.cs file to replace double brackets [][]
to single []
in EmailNotificationEventType
definition.
From Microsoft:
There is no resolution available at this point. However, three workarounds are available:
- You can generate the proxy class manually by using WSDL.exe and then change the proxy class in which the data type was inappropriately created as a two-dimensional array (for example, "CustomType[][]") so that it is a single-dimensional array (for example, "CustomType[]").
- You can change the data type in the desired Web Services Description Language (WSDL) so that a second, optional element is included in the definition. You can do this by adding an element such as the following:
<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 instead of being 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.)
Check also this link for further explanation.
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 instead of being 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 below:
Removed from the WSDL the minOccurs and maxOccurs for the NotificationEventsAvailable element [see the image below]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With