標籤:ade www 代理服務 uil erb 有一個 12px tar basic
自從引入ESB後,系統之間不再直接依賴。我負責的這塊,主要是解決Webservice的問題。使系統A不再直接依賴系統B的Webservice。我們選擇的產品是Mule ESB。所以自然要使用Mule 建立一個Webservice代理,即系統A請求到ESB,ESB請求系統B。
準備工作:通過我的部落格《Mule ESB-Basic Studio Tutorial》瞭解Mule ESB的基本操作。並準備開發環境。
環境:windows 8jdk 1.6mule-standalone-3.5.0-M4MuleStudio-for-win-32bit-3.5.0-201312091746
主要步驟:
1、建立一個Mule Project
2、建立一個流程
這兩步非常easy,不再贅述。操作結果:
3、編輯流程
(1)建立一個flow 開啟gxpt_test_esb_1.0.mflow,拖一個flow scope 進去。命名為HttpProxyService。
(2)加入HTTP Endpoint 加入HTTP Endpoint,而且右擊轉換為outbound endpoint,開啟屬性表單,輸入address。即Webservice的endpoint。如http://192.168.24.46:8080/test_server_webservice/UserManagerBean
(3)為這個Webservice建立一個client 加入一個SOAP Component到http endpoint的前面,編輯它的屬性,設定operation為proxy client
(4)建立一個真正的代理服務 加入還有一個SOAP Component到proxy client SOAP的前面,設定operation為proxy service。設定Namespace 和 Service,必須和你要代理的Webservice的wsdl相符。在WSDL Location中填上wsdl的地址,如http://192.168.24.46:8080/test_server_webservice/UserManagerBean?wsdl也能夠將該檔案放在項目的目錄中。如src/
(5)加入一個 HTTP inbound endpoint,設定address。如http://192.168.24.12:8888/UserManager
最後,完整的flow應該是以下這個樣子:
<?xml version="1.0" encoding="UTF-8"?><mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsdhttp://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsdhttp://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsdhttp://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"> <flow name="HttpProxyService" doc:name="HttpProxyService"> <http:inbound-endpoint exchange-pattern="request-response" address="http://192.168.24.12:8888/UserManager" doc:name="HTTP"/> <!-- wsdlLocation="service/UserManagerBean.wsdl" 也能夠使用該屬性替換掉url--> <cxf:proxy-service namespace="http://ejb.jialin.com/" service="UserManagerBean" payload="body" wsdlLocation="http://192.168.24.46:8080/test_server_webservice/UserManagerBean?wsdl" doc:name="SOAP"/> <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/> <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://192.168.24.46:8080/test_server_webservice/UserManagerBean" doc:name="HTTP"/> </flow> <flow name="gxpt_test_esb_1.0Flow1" doc:name="gxpt_test_esb_1.0Flow1"/></mule>
OK,接下你能夠run mule server,在瀏覽器中輸入wsdl地址。看一下結果啦。假設輸入Proxy 位址和直接輸入目標地址。顯示的wsdl一樣,說明配置正確。
小結:在這篇文章中,我介紹了怎樣使用mule建立一個Webservice代理,不須要使用不論什麼轉換器。也不須要寫一行代碼。全然是配置完畢的。
在興許文章中將繼續聊Mule ESB,敬請關注。
Mule ESB-3.Build a webservice proxy