How to Configure an SSIS Package to Access a Web Service using WCF
This information is from:http://blogs.msdn.com/b/dbrowne/archive/2010/07/08/how-to-configure-an-ssis-package-to-access-a-web-service-using-wcf.aspx
When you are connecting to a web service from an SSIS Script component or transform using a WCF client, the normal method of configuring the WCF client from the application configuration file doesn’t work well. Your package will be running in some host, like dtexec.exe, and you would have to put your client config its application configuration file. SSIS packages have their own way of consuming configuration, by either setting package variables (or other settings) from the command line, or using an external package configuration (stored in a SQL Server table or XML file). To use the normal SSIS configuration mechanisms to configure a WCF client, the easiest way is to configure your WCF client in code, and plug in package variables for things like the service URL, or perhaps the client credentials or proxy settings. If you configure the WCF client in code using this technique then you don't have to edit the dtexec.exe.config file.
Here’s a quick walkthrough of calling a Web Servcie from a WCF client in an SSIS package, configuring the WCF client in code and using a package variable for the web service URL.
First create a WCF Service for testing (or use some existing web service):
![]()
then hit F5 to run the service in the development server, and note the URL of the .svc file:
![]()
Create a new SSIS package and add a DataFlow and a Script Component configured to Source. Add output columns to the script source to match the data flowing out of the web service. Here it’s just a single integer.
![]()
Edit the script for the script source and change the target .NET Framework from 2.0 to 3.5 so you can use WCF:
![]()
In the Script project add a Service reference:
![]()
Enter the URL of your web service, and give it a friendly name:
![]()
Create a Package variable to configure the service URL, and give the script source read-only access to the variable.
![]()
Now edit the script to configure the WCF client in code and pass in the package variable for the URL.
/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/ using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.ServiceModel;
using SC_e9f00fa5cbb748d4b5b80e10f6c61d98.csproj.MyService; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{ ChannelFactory<IService1> channelFactory;
IService1 client;
public override void PreExecute()
{
base.PreExecute(); //create the binding
var binding = new WSHttpBinding();
//configure the binding
binding.Security.Mode = SecurityMode.Message;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; var endpointAddress = new EndpointAddress(this.Variables.ServiceUrl);
channelFactory = new ChannelFactory<IService1>(binding, endpointAddress); //create the channel
client = channelFactory.CreateChannel();
} public override void PostExecute()
{
base.PostExecute(); //close the channel
IClientChannel channel = (IClientChannel)client;
channel.Close(); //close the ChannelFactory
channelFactory.Close(); } public override void CreateNewOutputRows()
{ for (int i = ; i < ; i++)
{
this.Output0Buffer.AddRow();
CompositeType t = new CompositeType();
t.BoolValue = false;
t.StringValue = i.ToString(); var data = client.GetDataUsingDataContract(t);
this.Output0Buffer.id = data.BoolValue?:;
} } }
If you’re not sure what binding to use look at the app.config that the Add Service Reference wizard put in your script project. It will tell you. Here it requires wsHttpBinding with Message transport security and a Windows credential:
![]()
Add a simple data flow destination and test your package:
![]()
Then you can set the value of the package variable on the command line with dtexec.exe or SQL Agent, or create a package configuration that has sets them.
How to Configure an SSIS Package to Access a Web Service using WCF的更多相关文章
- 效率最高的Excel数据导入---(c#调用SSIS Package将数据库数据导入到Excel文件中【附源代码下载】) 转
效率最高的Excel数据导入---(c#调用SSIS Package将数据库数据导入到Excel文件中[附源代码下载]) 本文目录: (一)背景 (二)数据库数据导入到Excel的方法比较 ...
- 一次SSIS Package的调试经历
SSIS Package的调试有时是一个非常艰难的过程,由于SSIS 编译器给出的错误信息,可能并不完善,需要程序员根据错误信息抽丝拨茧,寻找错误的根源,进而解决问题. 第一部分:SSIS提供的调试工 ...
- 微软BI 之SSIS 系列 - 在 SSIS 中导入 ACCESS 数据库中的数据
开篇介绍 来自 天善学院 一个学员的问题,如何在 SSIS 中导入 ACCESS 数据表中的数据. 在 SSIS 中导入 ACCESS 数据库数据 ACCESS 实际上是一个轻量级的桌面数据库,直接使 ...
- 微软BI 之SSIS 系列 - 通过设置 CheckPoints 检查点来增强 SSIS Package 流程的重用性
开篇介绍 通常一个 ETL Package 是由多个控制流和数据流共同组成,有的时候 ETL 的步骤可能会比较多,整个流程执行下来的时间可能比较长.假设在 ETL Package 中包含5个Task, ...
- 微软BI 之SSIS 系列 - 利用 SSIS 模板快速开发 SSIS Package
开篇介绍 在做 ETL 项目的时候,往往很多 Package 的开发都是基于相同的模型和流程.比如在 Package 开始运行时需要向 Process Log 表中插入记录,在 Package 运行结 ...
- SQL Server(SSIS package) call .net DLL
There are two method to call .net DLL in SQLSERVER. The first one is to use the sql clr but it has a ...
- ssis package 在调试状态中设置断点,程序 不进入断点 的解决方案
原文:ssis package 在调试状态中设置断点,程序 不进入断点 的解决方案 针对 SSIS intergation 项目 > 属性 > Debug >Run64bITRunt ...
- SSIS Package to Call Web Service
原文 SSIS Package to Call Web Service SSIS Package to Call Web Service. You can Call WebService from S ...
- Agent Job代理 执行SSIS Package
摘要: 在使用Agent Job时, 运行SSIS包的Run as账号,必须有SSIS中connection manager的连接权限. 如果没有连接权限,可以用创建proxy账号,并确保proxy账 ...
随机推荐
- Bzoj2165 大楼
Time Limit: 40 Sec Memory Limit: 259 MBSubmit: 779 Solved: 285[Submit][Status][Discuss] Descriptio ...
- 【问题帖】压缩图片大小至指定Kb以下
像PS,QQ影像等都有该功能,将图片大小压缩至指定kb以下. 我也来山寨一把,到目前为止,控制图片的大小,平时的解决方案通过分辨率和质量来控制的. 假定最后压缩的大小是100kb,那么在保证不大于10 ...
- python3正则表达式符号和用法
- 腾讯微信支付,程序员是如何让jQuery代码付钱的
微信支付和支付宝支付已经是我们生活中不可确实的两个金融软件了,也是必备的,小编认为小钱用微信,大钱用支付宝. 下面这个图是我们生活中用腾讯微信支付平台的最后一个页面,大家想不想知道这个页面是如果做出来 ...
- 微信小程序实现豆瓣读书
个人练习项目,使用了scss+webstorm watcher来处理样式.整体上没有什么难点. github:https://github.com/axel10/wx-douban-read
- POJ 2528.Mayor's posters-线段树(成段替换、离散数据、简单hash)
POJ2528.Mayor's posters 这道题真的是线段数的经典的题目,因为数据很大,直接建树的话肯定不可以,所以需要将数据处理一下,没有接触离散化的时候感觉离散化这个东西相当高级,其实在不知 ...
- (6)java基础知识-基本数据类型、数据类型转换
一.基本数据类型 基本的数据类型一共有四类八种 1.整型 byte: 1字节 取值范围 -128~127 short: 2字节 取值范围 -32768~32767 int: 4字节 取 ...
- 51nod 1091 线段的重叠【贪心/区间覆盖类】
1091 线段的重叠 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 X轴上有N条线段,每条线段包括1个起点和终点.线段的重叠是这样来算的,[10 2 ...
- (转)代码中实现button
链接地址:http://www.cnblogs.com/hukezhu/p/4500206.html 随着iOS开发发展至今,在UI制作上逐渐分化为了三种主要流派:使用代码手写UI及布局:使用单个xi ...
- 七. 多线程编程6.isAlive()和join()的使用
如前所述,通常你希望主线程最后结束.在前面的例子中,这点是通过在main()中调用sleep()来实现的,经过足够长时间的延迟以确保所有子线程都先于主线程结束.然而,这不是一个令人满意的解决方法,它也 ...