reporting-services - 如何从 SSIS 包中调用 SSRS Soap?
问题描述
我正在处理来自 SQL Server 的数据,我会将其转换为文本文件,然后上传到 SSRS 文件夹。
我尝试使用 Web 服务任务组件,但它失败了。
知道我该如何解决这个问题吗?
解决方案
我在这里找到了脚本任务中的代码以及如何连接到 SSRS 并上传文件的解决方案。这是一种接受字节数组并使用用于运行 ssis 包的默认凭据上传到 SSRS 的方法,当然,该凭据还应该可以访问 ssrs 或您打算上传文件的 ssrs 中的特定文件夹。
protected bool UploadFile(byte[] data, string description)
{
var result = false;
try
{
if (data != null)
{
var fileName = string.Format("{0}_{1}_{2}{3}.zip", ZipPrefix, TargetDate, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"));
var prefix = string.Format("{0}_{1}", ZipPrefix, TargetDate);
ServiceManager.ReportingService2010 rs = new ServiceManager.ReportingService2010
{
Url = ServiceUrl,
RequestEncoding = Encoding.UTF8,
};
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
ServiceManager.Property[] properties = {
new ServiceManager.Property() { Name = "MimeType", Value = "application/zip" }
,new ServiceManager.Property(){ Name ="Description", Value = description}
};
var listItems = rs.ListChildren(SSRSFolder, false);
//var a = string.Join(", ", listItems.Select(x => x.Name));
//MessageBox.Show(a);
foreach (var item in listItems)
{
if (item.Name.Contains(prefix))
{
rs.DeleteItem(item.Path);
}
}
rs.CreateCatalogItem("Resource", fileName, SSRSFolder, false, data, properties, out ServiceManager.Warning[] warnings);
result = true;
}
}
catch (Exception e)
{
ErrorMessage = string.Format("Upload Error : {0}", e.Message);
Dts.Log(e.Message, 1, null);
throw new Exception(e.Message);
}
return result;
}
#endregion
请注意,我们需要向 SSRS Soap 添加服务引用。
推荐阅读
- c# - 如何使用 C# 和 XNA 进行双跳?
- c# - Breeze.net:在端点返回之前应用 ODATA 过滤器
- ms-access - 尝试查询多选列表框时出现错误 3131
- c++ - Microsoft C++ 异常:内存位置的 boost::archive::archive_exception(通过客户端服务器 Boost Udp 解析向量)
- android - 使用 ionic 3 编译 apk
- html - CSS和HTML定位的解释
- xamarin - 从 Proguard (Xamarin.Android) 获取 mapping.txt 文件
- javascript - 用 JavaScript 对数字进行四舍五入
- android - 清除所有图像会导致 ClassCastException 崩溃
- r - 如何为重叠点绘制不同颜色的散点图(如热图)?