需引用 System.Net;

windows集成验证:
        localhost.WebService math = new localhost.WebService();
        // Create a new instance of CredentialCache.
        CredentialCache credentialCache = new CredentialCache();
        // Create a new instance of NetworkCredential using the client
        // credentials.
        NetworkCredential credentials = new NetworkCredential("windows登录用户名", "登录密码");
        // Add the NetworkCredential to the CredentialCache.
        credentialCache.Add(new Uri(math.Url), "NTLM", credentials);
        // Add the CredentialCache to the proxy class credentials.
        math.Credentials = credentialCache;
        // Call the method on the proxy class.
        string Str = math.HelloWorld("keycom");

基本身份验证:
       localhost.WebService math = new localhost.WebService();
        math.Credentials = new System.Net.NetworkCredential("windows登录用户名", "登录密码");
        string Str = math.HelloWorld("keycom");

相关文章:

  • 2021-06-01
  • 2022-01-14
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-04-27
猜你喜欢
  • 2021-09-16
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-09-23
相关资源
相似解决方案