2011-07-10 25 views
0

我必須使用安全的(https)Web服務,這需要域用戶憑據。我有以下代碼來訪問該服務。在C中訪問安全的Web服務#

public string GetResponse() 
    { 
     var web = new ProxyStatisticsWebServiceSoapClient(); 
     web.ClientCredentials.Windows.AllowNtlm = true; 
     web.ClientCredentials.Windows.ClientCredential = new NetworkCredential("username", 
      "password", "domail"); 
     var result = web.QueryProxyStatistics(); 

     return result; 
    } 

每當我打電話web.QueryProxyStatistics();方法,我得到MessageSecurityException例外。 (該HTTP請求未經授權,客戶端認證方案爲'匿名',從服務器收到的認證頭是'NTLM'。)代碼有什麼問題嗎?

+0

你可以發佈你的客戶服務配置? – Khepri

回答

0

嘗試使用下面的代碼:

web.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; 
+0

試過仍然沒有快樂! –

+0

請發佈您的配置設置:服務器和客戶端。 – platon