HTTP状态407:需要代理身份验证调用Web服务时出错

时间:2009-10-27 05:43:33

标签: c# web-services authentication proxy

我在这个错误上花了两个小时“HTTP状态407:需要代理身份验证错误”,在调用Web服务时,我的代码如下:

WebProxy oWebProxy = new System.Net.WebProxy(ProxyServer, ProxyPort);
oWebProxy.Credentials = new NetworkCredential(ProxyUser,ProxyPassword,ProxyDomain);
oserv.Proxy = oWebProxy;
oserv.Credentials = new NetworkCredential(theusername, thepassword);

我已经验证代理地址,用户ID密码都是正确的,我可以通过IE在同一台PC上访问Web服务,但是当我用VS运行代码时,错误会保持弹出状态。 我也尝试了UserDefaultCredentials=true,但没有运气。

有什么想法吗?

2 个答案:

答案 0 :(得分:6)

使用<defaultProxy /><system.net>下的app.config / web.config中弹出useDefaultCredentials="true"元素可能会完成这项工作。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.net>
    <defaultProxy useDefaultCredentials="true" />
  </system.net>
</configuration>

答案 1 :(得分:-2)

尝试在安装了Web服务的同一网络上运行该应用程序

相关问题