2016-02-25 66 views
14

che io chiamo un servizio di terze parti e quando chiedo una risposta che getta fuori un'eccezione che diceautenticazione non è riuscita perché il partito a distanza ha chiuso l'eccezione flusso di trasporto quando ottenere una risposta da webservice

"Autenticazione non riuscito perché la parte remota ha chiuso l'eccezione del flusso di trasporto ".

Penso che ci sia un problema nell'invio delle credenziali. Ho perfino provato a fornire nuove credenziali. Ecco il codice completo

 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(); 

enter image description here

+1

http://stackoverflow.com/questions/19639846/failure-on-httpwebrequest-with-inner-exception-authentication-failed-because-the –

+0

ho provato questo, non risolve il problema. –

risposta

40

ho trovato la risposta, era perché il terzo webservice parte abbiamo chiamato non supportano TLS 1.0 hanno sostenuto 1.1 e 1.2. Quindi ho dovuto cambiare il protocollo di sicurezza.

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

dove posso aggiungere quel codice pls? –

+2

È possibile aggiungerlo prima di ottenere HTTPResponse dalla richiesta. –

+0

My SecurityProtocolType non mostra l'opzione per Tls12 e Tls11. Sto usando .net framework 4. –