调用web services提示Access Denied的解决办法[整理]
来源:互联网 发布:便签软件 编辑:程序博客网 时间:2024/05/17 04:37
现象:
asp.net中调用web services时提示错误:
请求因 HTTP 状态 401 失败:Access Denied。
将web services放到另一台服务器问题又不存在该问题。
解决办法:
1.新建方法:
#region GetCredentialCache
/// <summary>
/// 获取CredentialCache
/// 解决访问web service时提示没有权限的问题
/// </summary>
/// <returns></returns>
public static CredentialCache GetCredentialCache()
{
//权限验证web services地址
string WSUrl = RightsServicesUrl;
//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(WSUrl), "Negotiate", new NetworkCredential("域用户名", "域密码", "域"));
return cache;
}
#endregion
2.为web services指定CredentialCache
web services引用名为RightsControl,添加如下代码:
RightsControl rightsControl = new RightsControl();
//为web services指定CredentialCache,最重要的就是这一句
rightsControl.Credentials = GetCredentialCache();
//调用rightsControl的方法
- 调用web services提示Access Denied的解决办法[整理]
- 在mysql客户端提示Access Denied的解决办法
- putty登录出现access denied的解决办法
- access web.config denied
- Web Access Reporting Services
- 通过 spring/web services 调用 jdbcTemplate sql参数没填写出现的错误提示
- MySQL提示Access denied for user ''@'localhost'”的解决
- putty登录SSH终端出现的“Access Denied”提示
- Discuz 出现Access Denied错误提示的原因及解决方法
- MySQL提示Access denied for user ''@'localhost'”的解决
- 解决VS2017启动失败,提示Access Denied Error的问题
- Tomcat的Manager显示403 Access Denied的解决办法
- 登陆 SSH 出现 Access Denied 错误的解决办法
- vc6.0编译运行程序提示could not execute :Access denied (win32 error 5)解决办法
- mysql启动提示 access denied for user root@localhost(using password:YES) 解决办法总结
- AJAX 调用Web Services 的简单例子
- java调用.net的web services
- Ubuntu上使用jsp去连接mysql的时候踢提示Access denied for user 'root'@'localhost' (using password: YES)的解决办法!!!
- Small Basic语言解释器源代码
- 进程间通信
- 判断网页或图片加载完毕否- -
- dup and dup2
- 转贴诗一首
- 调用web services提示Access Denied的解决办法[整理]
- 学程序设计的人不能不看的好文章
- 面向对象设计(OOD)中的单一职责原则
- 自定义报表(demo1)
- 无题
- 如何才能将企业现有的组织关系集成到jbpm中?
- 关于VS2005与EVC4.2的项目开发过程中的问题点滴
- 寻找随机数
- mysql的几种超实用技巧