天天看點

Mule學習-簡單示例

開發工具:MuleStudio,可以直接去官網下載下傳。

建立新工程:File > New > Mule Project

因為我要做的執行個體是用ajax調用進行拼寫檢查,是以工程名為AjaxSpellChecker,隻要填寫工程名即可,其他都預設。

界面如下:

Mule學習-簡單示例

工程建立好後,我們來建立工作流,結果如下

Mule學習-簡單示例

我們建立一個簡單xml schema-transform.xsl用于接受參數控制,一個簡單的界面-src/main/app/docroot/SpellChecker.html

Mule學習-簡單示例
Mule學習-簡單示例

選中ajax,切換到Global Elements,在這個頁面建立一個Connecter

Mule學習-簡單示例
Mule學習-簡單示例

輕按兩下ajax,填寫服務通路路徑,選擇相應的連接配接器

Mule學習-簡單示例
Mule學習-簡單示例

輕按兩下xslt,選擇xsl檔案路徑

Mule學習-簡單示例

輕按兩下http,填寫通路資訊

Mule學習-簡單示例
Mule學習-簡單示例

儲存檔案,運作工程,在工程上點右鍵,Run As > Mule Application

正常啟動應該能看到:

**********************************************************************

* Application: ajaxspellchecker *

* OS encoding: GBK, Mule encoding: UTF-8 *

* *

* Agents Running: *

* Clustering Agent *

* JMX Agent *

**********************************************************************

INFO 2013-10-12 15:24:03,978 [main] org.mule.module.launcher.MuleDeploymentService:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ Started app ‘ajaxspellchecker’ +

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

在浏覽器通路http://localhost:8090/SpellChecker.html,再輸入框中輸入非正确的單詞,如下圖效果

Mule學習-簡單示例

至此,一個簡單的執行個體完成。

繼續閱讀