【问题标题】:HTTPS - 407 proxy authentication requiredHTTPS - 需要 407 代理身份验证
【发布时间】:2014-09-26 18:27:43
【问题描述】:

我正在使用以下代码调用我的合作伙伴网络服务。此代码运行良好,并且能够从我的 DEV 环境中的合作伙伴那里提取 xml 消息。但是,当我将此代码移动到集成环境时,它会给出错误407 proxy authentication required。当我联系我的网络团队时,他们说,我的代码正在尝试通过代理服务器进行调用。

但是,根据下面的代码,我没有配置任何东西来通过代理服务器调用合作伙伴服务。你能建议一下,我能做什么?

NetworkCredential creds = new NetworkCredential();

creds.UserName = "partner_client";
creds.Password = "dfasnc9d3";
HttpWebRequest hwRequest = (HttpWebRequest)HttpWebRequest.Create("https://res.dfadator.com/rest/requests/recent");
hwRequest.ContentType = System.Configuration.ConfigurationManager.AppSettings.Get("ContentType");
hwRequest.Method = System.Configuration.ConfigurationManager.AppSettings.Get("Method"); ;

hwRequest.Credentials = creds;

// Parse the Response.
webResponse = (HttpWebResponse)hwRequest.GetResponse();

【问题讨论】:

    标签: .net web-services https proxy httpwebrequest


    【解决方案1】:

    上述方法调用代理服务器,如果代理服务器设置启用UseProxy。
    我在拨打电话时绕过代理服务器解决了这个问题。

    string sProxyWebAddress = null;
    System.Net.WebProxy wbProxy = new System.Net.WebProxy(sProxyWebAddress, true);
    hwRequest.Proxy = wbProxy;
    wbProxy = null;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多