1
我正在使用第三方wsdl連接到服務。我已提供安全證書和用戶名/密碼。以C#連接到Web服務的問題
我:
- 安裝在我的Windows 7計算機
- 有保證的它具有正確的權限
- 有正確的位置存儲在web.config中的API上的證書
代碼每次都失敗。錯誤消息更改,但它們包括:
- 由於遠程方已關閉傳輸流,因此身份驗證失敗。
- 一個現有的連接被強行關閉遠程主機
- 無法建立SSL/TLS安全通道
這是我執行的代碼:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
//Third party client
var client = new ConnectionPortClient();
//Including these two lines or not does not affect the outcome
//client.ClientCredentials.UserName.UserName = "username";
//client.ClientCredentials.UserName.Password = "password";
client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(@"C:\..\cert.p12", "password", X509KeyStorageFlags.MachineKeySet);
var results = client.getResults("");
而且這裏是有關部分web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="assessmentBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://endpoint/" binding="basicHttpBinding"
bindingConfiguration="assessmentBinding" contract="API.Assessment"
name="assessmentSOAP" />
</client>
</system.serviceModel>
對這裏發生了什麼有什麼想法?
即使刪除用戶名和密碼的兩行似乎沒有區別(我嘗試的一切嘗試,沒有這兩行以防萬一) – 2012-08-13 23:59:42
是的..它應該是另一個錯誤。會覺得 – 2012-08-14 02:31:18