user1408767
user1408767

Reputation: 677

Fedex API using c# get rates for freight, why am I getting an error

I downloaded sample code from the Fedex site in order to call an api in order to get rate for a specific freight. The program is RateWebServiceClient.

I created test credentials and entered in the test key, password, account number, and meter number. The service url is https://wsbeta.fedex.com:443/web-services/rate. When I call the service.GetRates by passing in the RateRequest object, I get the following exception:

The underlying connection was closed: An unexpected error occurred on a send. Received an unexpected EOF or 0 bytes from the transport stream.

I then created production credentials and changed the key, password, account number and meter number and I changed the service url to https://ws.fedex.com:443/web-services/rate. Now I get the following SoapException:

UnrecoverableClientErrorSchemaErrorvalidation failure for RateRequest Error:cvc-elt.1: Cannot find the declaration of element 'RateRequest'.

I'm not sure what I am missing or if I am possibly calling the incorrect web service url or something else.

Upvotes: 0

Views: 1128

Answers (2)

Acanocois
Acanocois

Reputation: 33

I had to use do this in C#:

using System.Security.Authentication;

Create 2 constants:

public const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
public const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;

Use like this :

ServicePointManager.SecurityProtocol = Tls12;

Upvotes: 1

Deepika Selvaraj
Deepika Selvaraj

Reputation: 1

In C#,

using System.Web.Services.Protocols;
using System.Net;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Upvotes: 0

Related Questions