如果您已經獲得了使用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