我必須使用安全的(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'。)代碼有什麼問題嗎?
你可以發佈你的客戶服務配置? – Khepri