首页 > 解决方案 > SSIS 脚本转换错误远程服务器返回错误:(407) 需要代理身份验证

问题描述

我正在使用 SQL Server 和 Visual Studio 2019。我有一个 SSIS 包,它使用脚本转换作为从 Web 服务中提取数据的源 (c#)。当我在笔记本电脑上通过 Visual Studio 执行时,一切都可以 100% 运行。当我部署到 SSIS 目录并执行时,我不断收到错误消息:

Error The remote server returned an error: (407) Proxy Authentication Required

这是我的代码片段:

public class ScriptMain : UserComponent
{
    string json;
    DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    public override void PreExecute()
    {
        base.PreExecute();
        ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        
        string fullurl = Variables.FullURL;

        string url = fullurl;

        json = DownloadJson(url);
    }

我正在使用包含所有登录名和密码信息的变量(上面的 fullurl)构建 url。我需要修改它还是公司网络上的某些东西阻止了它?

标签: c#jsonsql-serverweb-servicesssis

解决方案


身份验证的方式很少出现在查询字符串中。可以,但通常不是。

试试这个...

var wc = new System.Net.WebClient();
wc.Credential = new NetworkCredential([username],[password]);
string json = wc.DownLoadString(url);

在 PreExecute 部分执行此操作也是不寻常的。您通常在脚本组件源的添加行部分执行此操作。


推荐阅读