2017-03-06 123 views
1

請幫助我的人, 當調用第三方Web服務,它表明:請求已中止:無法創建SSL/TLS安全通道的.Net 4.5.2

Initializing 
Generating WSDL 
System.InvalidOperationException: General Error https://xxx ---> System.Net.WebException: There was an error downloading 'https:/xxx'. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. 
    at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) 
    at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) 
    at System.Web.Services.Discovery.DiscoveryClientProtocol.Download(String& url, String& contentType) 
    --- End of inner exception stack trace --- 
    at System.Web.Services.Discovery.DiscoveryClientProtocol.Download(String& url, String& contentType) 
    at System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoverAny(String url) 
    at WebServiceStudio.Wsdl.ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions) 
    --- End of inner exception stack trace --- 
    at WebServiceStudio.Wsdl.ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions) 
    at WebServiceStudio.Wsdl.Generate() 

我已經嘗試使用X509證書,給予用戶全部權限。

+0

1)檢查事件日誌。 2)你可以在瀏覽器中訪問端點嗎? – Ben

+0

我無法訪問端點,因爲無法從瀏覽器(https)訪問web服務。我該怎麼辦 ? –

+0

如果端點根本無法訪問*這不是一個編程問題。與供應商交談:服務是否已啓動?你有沒有正確的網址?與您的網絡管理員聯繫。防火牆是否阻止了它? – Ben

回答

0

當Web服務的SSL證書無效時可能會發生這種情況。

要解決該問題,請嘗試以下代碼:

System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(delegate 
{ 
    return true; 
}); 

如果這能解決您的問題,那麼你應該檢查你的機器上的證書。

正如@ dman2306所說,這只是爲了檢查證書是否是問題的原因。 請勿在任何生產代碼中使用此項。

+2

我覺得澄清你的意思很重要:這個代碼不應該在生產環境中使用。 @plusheen建議你使用它來測試你是否有證書問題,而不是解決方法。 – dman2306

+0

@ dman2306好點,補充說明。 – plusheen

+0

我已經嘗試了這種解決方法,仍然沒有線索 –

相關問題