c# - 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。我需要修改它还是公司网络上的某些东西阻止了它?
解决方案
身份验证的方式很少出现在查询字符串中。可以,但通常不是。
试试这个...
var wc = new System.Net.WebClient();
wc.Credential = new NetworkCredential([username],[password]);
string json = wc.DownLoadString(url);
在 PreExecute 部分执行此操作也是不寻常的。您通常在脚本组件源的添加行部分执行此操作。
推荐阅读
- javascript - 在 Chart js 中更新图表
- python - 如何在 Python 中合并多个列表
- loopbackjs - 将 LoopBack 应用程序连接到现有 MySQL 数据库
- string - 使用 PowerShell 将字符串解析为对象时遇到问题
- python - Python 函数中的输入参数
- makefile - 将路径字符串列表解析为make中不同路径的更好方法?
- r - rbind 一个空的 xts 和一个 xts
- c++ - 在类定义中推导内联静态成员函数的返回类型
- docker - Kubernetes 组合
- python - 如何使用 TensorFlow 连接两个具有不同形状的张量?