身份验证失败,因为在从Web服务获得响应时,远程方已关闭传输流异常 [英] Authentication failed because the remote party has closed the transport stream exception when getting a response from webservice

查看:367
本文介绍了身份验证失败,因为在从Web服务获得响应时,远程方已关闭传输流异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在致电第三方服务,当我要求响应时,它会抛出一个异常,提示

I am calling a third party service and when I ask for a response it throws out an exception that says

验证失败,因为远程方已关闭传输流异常".

"Authentication failed because the remote party has closed the transport stream exception".

我认为发送凭据时出现问题.我什至尝试提供新的凭据.这是完整的代码

I think that there is a problem in sending credentials. I have even tried supplying new credentials. Here is the full code

string get_url = "https://**.*******.com/com/******/webservices/public_webservice.cfc?wsdl&Method=CreateUser&SiteID=**&WSPassword=******&UserName=******";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(get_url);
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
request.Credentials = CredentialCache.DefaultCredentials;
//request.UseDefaultCredentials = false;
//request.Credentials = new System.Net.NetworkCredential("*****", "*****");
request.ContentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";

// Show the sent stream
//lbl_send_stream.Text = send_stream;
//lbl_send_stream.Text = get_url;
// Get UserId And LoginToken From Third Party DB
// ==============================================
//Exception gets throwed When code hits here
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

推荐答案

我找到了答案,这是因为我们调用的第三方Web服务不支持TLS 1.0,而他们支持1.1和1.2.所以我不得不更改安全协议.

I found the answer, It was because the third party webservice we were calling did not support TLS 1.0 they supported 1.1 and 1.2. So I had to change the security protocol.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

这篇关于身份验证失败,因为在从Web服务获得响应时,远程方已关闭传输流异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆