请求因 HTTP 状态 401 失败:Access Denied。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Net.WebException: 请求因 HTTP 状态 401 失败:Access Denied。源错误: 
行 36:         [return: System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
行 37:         public System.Byte[] YanZhengPicture() {
行 38:             object[] results = this.Invoke("YanZhengPicture", new object[0]);
行 39:             return ((System.Byte[])(results[0]));
行 40:         }
 源文件: D:\Bank\Web References\YanZhengPicture\Reference.cs    行: 38

解决方案 »

  1.   

    请求因 HTTP 状态 401 失败:Access Denied。 
    中文意思是:拒绝登录 
    换一句话就是说你没有权限,解决方法是将文件爽的everyone访问权限打开
      

  2.   

    可能是是匿名访问的问题,在iis信息服务器上把匿名访问给勾上试试看
      

  3.   

    症状
    当您尝试调用 Web 服务应用程序并且匿名访问身份验证处于关闭状态时,可能会收到以下错误信息。
    The request failed with HTTP status 401:Access Denied.
    原因
    当匿名访问身份验证对 Web 服务应用程序关闭时,所有的调用方应用程序在发出任何请求之前必须提供凭据。默认情况下,Web 服务客户端代理不继承运行 Web 服务客户端应用程序的安全上下文的凭据。
    解决方案
    要解决这个问题,必须使用 Web 服务客户端代理的凭据属性为 Web 服务客户端身份验证设置安全凭据。要设置凭据属性,请执行下列操作之一: • 第一种方法
    将 DefaultCredentials 分配给 Web 服务代理类的凭据属性,以在匿名访问身份验证关闭时调用 Web 服务。CredentialCache 类的 DefaultCredentials 属性提供运行应用程序的安全上下文的系统凭据。为此,请使用以下代码:Visual C# .NET 示例//Assigning DefaultCredentials to the Credentials property
    //of the Web service client proxy (myProxy).
    myProxy.Credentials= System.Net.CredentialCache.DefaultCredentials;Visual Basic .NET 示例'Assigning DefaultCredentials to the Credentials property
    'of the Web service client proxy (myProxy).
    myProxy.Credentials= System.Net.CredentialCache.DefaultCredentials
     第二种方法
    您还可以使用 CredentialCache 类为 Web 服务客户端身份验证提供凭据。创建 CredentialCache 类的实例。创建使用指定的用户名、密码和域的 NetworkCredential 的实例。将 NetworkCredential 添加到具有身份验证类型的 CredentialCache 类。为此,请使用以下代码:Visual C# .NET 示例//Create an instance of the CredentialCache class.
    CredentialCache cache = new CredentialCache();// Add a NetworkCredential instance to CredentialCache.
    // Negotiate for NTLM or Kerberos authentication.
    cache.Add( new Uri(myProxy.Url), "Negotiate", new NetworkCredential("UserName", "Password", "Domain"));//Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property.
    myProxy.Credentials = cache;
    Visual Basic .NET 示例'Create an instance of the CredentialCache class.
    Dim cache As CredentialCache = New CredentialCache()'Add a NetworkCredential instance to CredentialCache.
    'Negotiate for NTLM or Kerberos authentication.
    cache.Add(New Uri(myProxy.Url), "Negotiate", New NetworkCredential("UserName", "Password", "Domain"))'Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property.
    myProxy.Credentials = cache
     
    注意:CredentialCache 类和 NetworkCredential 类属于 System.Net 命名空间。