构建一个Hello World应用程序
假设
本教程假设您拥有的 下载,安装并启动了Mule工作室 , 你阅读 Mule工作室的必需品 。
创建一个新项目
- 在工作室中,单击 File 然后选择 New > Mule Project 。
- 工作室打开 New Mule Project 向导。 在 Name 字段中,输入的值
, 然后单击 Finish。My First Project

- 打开一个空白的画布。 开始设计您的项目通过拖拽 HTTP Endpoint 从 palette 到 canvas 。 请注意,Studio自动包装的端点 flow,从而节省您的步骤手动创建一个。

-
添加到流的 Echo Component ,拖着它旁边的HTTP端点在画布上。 单击 Configuration XML 选项卡(底部的画布上)看到您的应用程序用XML表示。 工作室的双向编辑功能可以确保你在图形界面中添加或更改反映在XML配置。 (使用下面的选项卡来查看应用程序的图形和XML表示)。

- 单击 Message Flow 选项卡回到图形化编辑器,然后单击 save 图标来保存您的项目。
配置项目
既然已经建模工作室基本的应用程序,你可以采取的步骤配置每个单独的元素。
- 在画布上单击HTTP端点开放 Properties Editor 在控制台(见下图)。
- HTTP端点 允许Mule应用程序连接到Web资源通过HTTP或HTTPS协议。 在一个更复杂的应用程序中,您将使用这个编辑器来配置端点的值的属性,定义应用程序的连接细节。 对于这个项目,k 所有字段保留默认值。

- 单击 Echo Component 在画布上开放 Properties Editor 在控制台(见下图)。
- 回声组件仅返回响应HTTP请求消息有效负载。 对于这个项目,k 所有字段保留默认值。

-
再次,您可以单击 Configuration XML 查看您的更改在XML配置(请参见下面的代码)。 单击 save 图标以保存您的更改。
<?xmlversion="1.0"encoding="UTF-8"?><mulexmlns:http="<a href="http://www.mulesoft.org/schema/mule/http" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.mulesoft.org/schema/mule/http"xmlns="<a href="http://www.mulesoft.org/schema/mule/core" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.mulesoft.org/schema/mule/core"xmlns:doc="<a href="http://www.mulesoft.org/schema/mule/documentation" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.mulesoft.org/schema/mule/documentation"xmlns:spring="<a href="http://www.springframework.org/schema/beans" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.springframework.org/schema/beans"version="EE-3.4.0"xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-current.xsdhttp://www.mulesoft.org/schema/mule/http <a href="http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd" "="" style="color: rgb(0, 136, 204); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.2em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: inherit !important; background: none !important;">http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd"><flowname="My_First_MuleFlow1"doc:name="My_First_MuleFlow1"><http:inbound-endpointexchange-pattern="request-response"host="localhost"port="8081"doc:name="HTTP"/><echo-componentdoc:name="Echo"/></flow></mule>
部署项目
Mule工作室有自己的嵌入式服务器捆绑在一起,适合测试时部署代码。 嵌入式服务器上部署您的应用程序可以看到它工作和执行任何调试活动部署到生产环境之前如一个服务器或前提 CloudHub 。
- 在 Package Explorer右键单击项目名称,然后选择 Run As > Mule Application 。
- 工作室嵌入式服务器上启动应用程序,显示在控制台的行为。 完成后,控制台消息读取
Started app 'my_first_project'

与项目交流
- 打开一个Web浏览器。
- 导航到您的应用程序的URL,附加一个字符串,成为消息有效负载。 例如:
http://localhost:8081 / Hello_world
- 接受请求的应用程序通过HTTP端点,然后“回声”相同的载荷响应在您的浏览器中。

- 在工作室,停止应用程序使用 terminate 图标在控制台(见下文)。

本文介绍如何使用Mule Studio创建一个简单的HelloWorld应用程序。包括项目的创建、配置及部署过程。
6821

被折叠的 条评论
为什么被折叠?



