天天看點

使用WebSphere Integration Developer 7開發Business Integration Hello World應用程式

本文總結了使用WebSphere Integration Developer 7開發和測試一個Business Integration Hello World應用程式的過程。 該應用程式讀取一個本地的CVS檔案,将其轉換輸出為XML格式檔案。

第1步 - 安裝WebSphere Integration Developer 7.0

安裝IID 7.0.0.4和本地Websphere Process server測試環境。

第2步 - 開發Hello World Business Integration應用

2.1) 使用菜單File - New - Module以建立一個新的module, 并命名為SimpleFileModul。

2.2) 在Business Object Parsing Mode界面中使用預設值, 點選Finish. module建立完畢後, 會顯示Assemble Diagram視圖。

2.3) 在SimpleFileModule下, 右鍵點選Data Types以建立一個新的Business Object。

2.4) 輸入Customer為Business Object名稱, 點選Next。

2.5) 在Derived Business Object界面下, 點選Finish。

2.6) 切換到Business Object編輯器。

2.7) 點選Add Field圖示在Customer Business Object中新增資料字段。

2.8) 建立一個字元字段name和一個整數字段age, 并儲存檔案。

2.9) 右鍵點選SimpleFileModule并選擇New - External Service。

2.10) 選擇Simple inbound Flat File service to read from a local file, 點選Next。

2.11) 在Flat File service name界面中使用預設值, 點選Next。

2.12) 當CWYFF_FlatFile 工程被導入到workspace後. 在Business object and directory界面中, 選擇Customer為Business object, 指定輸入目錄. 點選Next。

2.13) 選擇Other為輸入格式, 并選擇CSVDataHandler。

2.14) 使用"\n"為檔案分隔符, 點選Next。

2.15) 指定本地存檔目錄, 點選Finish。

2.16) 新增的FlatFileExportinterface出現在Assemble Diagram中。

2.17) 右鍵點選SimpleFileModule并選擇New - External Service以添加Simple outbound Flat File service to write to a local file, 點選Next。

2.18)在Flat File service name界面下使用預設值, 點選Next。

2.19)在Business object and directory界面下,選擇Customer Business object并指定輸出目錄, 點選Next。

2.20)在Output file name界面下, 指定輸出檔案名為Customer.xml, 點選Next。

2.21) 使用XML輸出格式, 點選Finish。

2.22)新增的FlatFileImport interface出現在Assemble Diagram中。

2.23)從Assemble Diagram Paletter中拖拉一個Mediation Flow到Assemble Diagram編輯器中.

2.24)命名該Mediation Flow為SimpleFileFlow

2.25)輕按兩下SimpleFileFlow, 在确認消息框中點選Yes.

2.26) 在Generate Implementation下使用預設值, 并點選OK。

2.27) 切換到SimpleFileFlow編輯器。

2.28) 點選Add an interface連結并選擇FlatFileExport。

2.29) 點選Add a reference連結并選擇FlatFileImport。

2.30) 儲存所有檔案。

2.31) 在FlatFileExport下點選emit連結, 并選擇Operation Map。

2.32) 在Select Reference Operation界面下使用預設值, 點選OK。

2.33) 切換到Mediation Flow Request編輯器。

2.34) 輕按兩下input_map節點, 在Create an XML Map界面下使用預設值, 并點選Next。

2.35) 在Specify Message Types界面下使用預設值, 并點選Finish。

2.36) 切換到map編輯器, 擴充emit和create連結。

2.37) 使用一個Move轉換以連接配接emitInput和createInput。

2.38) 儲存所有檔案并切換到Assemble Diagram, 連接配接FlatFileExport到SimpleFileFlow, 以及SimpleFileFlow到FlatFileImport, 儲存檔案。

第3步 - 測試應用程式

右擊本地Process Server并選擇Add and Remove Projects。

添加SimpleFileModuleApp, 并點選Finish。

啟動Process Server, 确認SimpleFileModuleApp啟動和同步正常完成。

向指定的輸入目錄下複制一個以下格式的CSV檔案。

Peter,20
Tom,21
Emma,22
Julia,23
      

幾秒中之後, 應用程式會讀取該CSV檔案, 并将其轉換為XML格式并輸出到指定的目錄下, 輸入檔案則被移到本地存檔目錄下,其檔案擴充名變為.success或.fail。 生成的XML檔案格式如下。

<?xml version="1.0" encoding="UTF-8"?>
<p:Customer xsi:type="p:Customer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:p="http://SimpleFileModule">
	
	<name>Tom</name>
	<age>21</age>
</p:Customer>