如果您已经获得了使用web服务的脚本,则可以跳过所有中间输出并将其用作数据流中的源代码。
将数据流任务拖动到画布上并添加脚本组件。而不是选择转换(最后一个选项),请选择Source
。
双击脚本组件并选择Input and Output Properties
。在“输出0”下,选择“输出列”,然后单击“Add Column
”以查看Web服务具有的许多列。适当命名它们并确保正确定义它们的元数据。
定义列后,单击回到脚本选项卡,选择您的语言并编辑脚本。将所有可能编写的代码都用于服务,我们将在此处使用它。
在CreateNewOutputRows
方法中,您将需要遍历Websphere MQ请求的结果。对于返回的每一行,您将应用以下模式。
public override void CreateNewOutputRows()
{
// TODO: Add code here or in the PreExecute to fill the iterable object, mqcollection
foreach (var row in mqcollection)
{
// Adds a new row into the downstream buffer
Output0Buffer.AddRow();
// Assign all the data to the correct locations
Output0Buffer.Column = row.Column;
Output0Buffer.Column1 = row.Column1;
// handle nulls appropriately
if (string.IsNullOrEmpty(row.Column2))
{
Output0Buffer.Column2_IsNull = true;
}
else
{
Output0Buffer.Column2 = row.Column2;
}
}
}
您必须通过_IsNull属性或你的脚本将炸毁处理空值。这是繁琐的工作而不是正常的来源,但与转储到磁盘或其他分段机制相比,您将更有效率,更快速并消耗更少的资源。
这正是我所期待的。非常感谢您的详细解释! – DZx 2012-02-27 15:43:35
如果你觉得这个和其他答案很有用,你可以点击问题旁边的向上箭头。如果这解决了您的问题,您也可以单击复选标记以表示问题已得到解答。 – billinkc 2012-02-27 16:05:54