2012-08-31 62 views
2

我已經提供了wcf服務url,私有和公共證書來使用它。帶證書認證的WCF服務參考

My url is https:/xxxx.com/xxxx/xxxx.svc 
my private certificate is xxx.pfx 
my public certificate is xxxx.cer 

當我嘗試從我的客戶端應用程序添加服務引用時,它會引發以下錯誤。

There was an error downloading 
'https://xxxx.com/xxxx/xxxx.svc'. 
The underlying connection was closed: 
An unexpected error occurred on a receive. 
Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host. 
An existing connection was forcibly closed by the remote host 
Metadata contains a reference that cannot be resolved: 
'https://xxxx.com/xxxx/xxxx.svc'. 
An error occurred while receiving the HTTP response to 
https://xxxx.com/xxxx/xxxx.svc. 
This could be due to the service endpoint binding not using the HTTP protocol. 
This could also be due to an HTTP request context being aborted by the server 
(possibly due to the service shutting down). 
See server logs for more details. 
The underlying connection was closed: An unexpected error occurred on a receive. 
Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host. 
An existing connection was forcibly closed by the remote host 
If the service is defined in the current solution, 
try building the solution and adding the service reference again. 

我有證書安裝在個人,受信任的人,受信任的publishers文件夾下。我無法訪問服務器來檢查服務器配置。但是我被告知這是爲不同的客戶服務的。我相信我搞亂了證書的安裝。如果有人能指引我走向正確的方向,那將會很棒。

感謝,

也先

回答

1

你必須啓用跟蹤才能看到服務器上發生了什麼。您發佈的錯誤消息更通用。

http://msdn.microsoft.com/en-us/library/ff648360.aspx http://msdn.microsoft.com/en-us/library/ms733025.aspx

+0

感謝我展示的路徑找到問題。跟蹤幫助我們找出服務器中的問題。問題是證書未安裝在可信文件夾中。 – Esen

0

最初只是嘗試從項目中刪除服務引用,從web.config中刪除system.ServiceModel部分,然後重新添加服務引用。這將強制VS完成重建system.ServiceModel部分。如果這不能幫助其他wcf客戶端配置是必需的。 這裏是偉大的樣本如何正確配置WCF客戶端使用證書:

http://www.codeproject.com/Articles/28248/Securing-WCF-Services-with-Certificates

如果您仍然遇到在此之後的問題,你可能會錯過一些自定義endpointBehavior。在這種情況下,您應該聯繫wcf服務提供商。