Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
联邦快递API使用c#获取运费费率,为什么我会得到一个错误_C#_Api_Fedex - Fatal编程技术网

联邦快递API使用c#获取运费费率,为什么我会得到一个错误

联邦快递API使用c#获取运费费率,为什么我会得到一个错误,c#,api,fedex,C#,Api,Fedex,我从联邦快递网站下载了示例代码,以便调用api以获取特定运费的费率。该程序是RateWebServiceClient 我创建了测试凭据并输入了测试密钥、密码、帐号和仪表号。服务url为。通过传入RateRequest对象调用service.GetRates时,会出现以下异常: 基础连接已关闭:发送时发生意外错误。 从传输流接收到意外的EOF或0字节 然后我创建了生产凭证,更改了密钥、密码、帐号和仪表号,并将服务url更改为。现在我得到以下SoapException: RateRequest错误的

我从联邦快递网站下载了示例代码,以便调用api以获取特定运费的费率。该程序是RateWebServiceClient

我创建了测试凭据并输入了测试密钥、密码、帐号和仪表号。服务url为。通过传入RateRequest对象调用service.GetRates时,会出现以下异常:

基础连接已关闭:发送时发生意外错误。 从传输流接收到意外的EOF或0字节

然后我创建了生产凭证,更改了密钥、密码、帐号和仪表号,并将服务url更改为。现在我得到以下SoapException:

RateRequest错误的不可恢复ClientErrorSchemaErrorValidation失败:cvc elt。1:找不到元素“RateRequest”的声明

我不确定我遗漏了什么,或者我是否可能调用了错误的web服务url或其他内容

我必须用C#来做这件事:

创建两个常量:

public const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
public const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
这样使用:

ServicePointManager.SecurityProtocol = Tls12;

它帮助了我,谢谢:)
public const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
public const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
ServicePointManager.SecurityProtocol = Tls12;