开发者

Access Secured Web service in C#

I have to consume a secured (https) web service, which requires a domain user credentials. I have following code to access the service.

    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;
    }

Whenever I call web.QueryProxyStatistics(); method, I get MessageSecurityException exceptions. (The HTTP request is u开发者_开发百科nauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'.) is there anything wrong with code?


Try to use the following code:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜