Mule ESB-3.Build a webservice proxy
生活随笔
收集整理的這篇文章主要介紹了
Mule ESB-3.Build a webservice proxy
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
自從引入ESB后,系統(tǒng)之間不再直接依賴,我負責(zé)的這塊,主要是解決Webservice的問題,使系統(tǒng)A不再直接依賴系統(tǒng)B的Webservice。
我們選擇的產(chǎn)品是Mule ESB,所以自然要使用Mule 創(chuàng)建一個Webservice代理,即系統(tǒng)A請求到ESB,ESB請求系統(tǒng)B。
準備工作: 通過我的博客《Mule ESB-Basic Studio Tutorial》了解Mule ESB的基本操作,并準備開發(fā)環(huán)境。
環(huán)境: windows 8 jdk 1.6 mule-standalone-3.5.0-M4 MuleStudio-for-win-32bit-3.5.0-201312091746
主要步驟: 1、新建一個Mule Project 2、創(chuàng)建一個流程
這兩步很簡單,不再贅述,操作結(jié)果:
3、編輯流程 (1)新建一個flow 打開gxpt_test_esb_1.0.mflow,拖一個flow scope 進去,命名為HttpProxyService。
? (2)添加HTTP Endpoint 添加HTTP Endpoint,并且右擊轉(zhuǎn)換為outbound endpoint,打開屬性窗口,輸入address,即Webservice的endpoint。如http://192.168.24.46:8080/test_server_webservice/UserManagerBean
(3)為這個Webservice創(chuàng)建一個客戶端 ? ??? ??? ??添加一個SOAP Component到http endpoint的前面,編輯它的屬性,設(shè)置operation為proxy client ? ? ?(4)創(chuàng)建一個真正的代理服務(wù) ? ??添加另一個SOAP Component到proxy client SOAP的前面,設(shè)置operation為proxy service,設(shè)置Namespace 和 Service,必須和你要代理的Webservice的wsdl相符。在WSDL Location中填上wsdl的地址,如http://192.168.24.46:8080/test_server_webservice/UserManagerBean?wsdl 也可以將該文件放在項目的文件夾中,如src/ (5)添加一個?HTTP inbound endpoint,設(shè)置address,如http://192.168.24.12:8888/UserManager? ?
最后,完整的flow應(yīng)該是下面這個樣子:
[html] view plaincopyprint?<?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.xsd?? http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-current.xsd?? http://www.mulesoft.org/schema/mule/core?http://www.mulesoft.org/schema/mule/core/current/mule.xsd?? http://www.mulesoft.org/schema/mule/cxf?http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd?? http://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>?? <?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.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://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地址,看一下結(jié)果啦。 如果輸入代理地址和直接輸入目標地址,顯示的wsdl一樣,說明配置正確。
小結(jié): 在這篇文章中,我介紹了如何使用mule創(chuàng)建一個Webservice代理,不需要使用任何轉(zhuǎn)換器,也不需要寫一行代碼,完全是配置完成的。
在后續(xù)文章中將繼續(xù)聊Mule ESB,敬請關(guān)注。 與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖
準備工作: 通過我的博客《Mule ESB-Basic Studio Tutorial》了解Mule ESB的基本操作,并準備開發(fā)環(huán)境。
環(huán)境: windows 8 jdk 1.6 mule-standalone-3.5.0-M4 MuleStudio-for-win-32bit-3.5.0-201312091746
主要步驟: 1、新建一個Mule Project 2、創(chuàng)建一個流程
這兩步很簡單,不再贅述,操作結(jié)果:
3、編輯流程 (1)新建一個flow 打開gxpt_test_esb_1.0.mflow,拖一個flow scope 進去,命名為HttpProxyService。
? (2)添加HTTP Endpoint 添加HTTP Endpoint,并且右擊轉(zhuǎn)換為outbound endpoint,打開屬性窗口,輸入address,即Webservice的endpoint。如http://192.168.24.46:8080/test_server_webservice/UserManagerBean
(3)為這個Webservice創(chuàng)建一個客戶端 ? ??? ??? ??添加一個SOAP Component到http endpoint的前面,編輯它的屬性,設(shè)置operation為proxy client ? ? ?(4)創(chuàng)建一個真正的代理服務(wù) ? ??添加另一個SOAP Component到proxy client SOAP的前面,設(shè)置operation為proxy service,設(shè)置Namespace 和 Service,必須和你要代理的Webservice的wsdl相符。在WSDL Location中填上wsdl的地址,如http://192.168.24.46:8080/test_server_webservice/UserManagerBean?wsdl 也可以將該文件放在項目的文件夾中,如src/ (5)添加一個?HTTP inbound endpoint,設(shè)置address,如http://192.168.24.12:8888/UserManager? ?
最后,完整的flow應(yīng)該是下面這個樣子:
[html] view plaincopyprint?
OK,接下你可以run mule server,在瀏覽器中輸入wsdl地址,看一下結(jié)果啦。 如果輸入代理地址和直接輸入目標地址,顯示的wsdl一樣,說明配置正確。
小結(jié): 在這篇文章中,我介紹了如何使用mule創(chuàng)建一個Webservice代理,不需要使用任何轉(zhuǎn)換器,也不需要寫一行代碼,完全是配置完成的。
在后續(xù)文章中將繼續(xù)聊Mule ESB,敬請關(guān)注。 與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖
總結(jié)
以上是生活随笔為你收集整理的Mule ESB-3.Build a webservice proxy的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 比亚迪S6远近灯光不亮?按喇叭就亮了这是
- 下一篇: poi方式写入数据到Excel