日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mule ESB 学习笔记(11)Web Service Proxy(这里是一个可以正常运行的例子)

發布時間:2024/9/27 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mule ESB 学习笔记(11)Web Service Proxy(这里是一个可以正常运行的例子) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、WebSevice Proxy?簡介


???? WebService Proxy?ESB中最常見的使用場景之一,即通過?ESB?直接轉發?WebService Client??SOAP?請求,并將?WebServcie

Provider??SOAP?響應轉發給?WebService Client?,此時的ESB就是一個WebService Proxy

?

二、WebSevice Proxy??Mule?中的產生背景
?????? Mule3.0?新增了一些比較有亮點的新特性?,其中包括“?pattern-based configuration?”這個概念。?pattern-based configuration

的主要目是將常用的功能模式化,達到簡化配置文件的目的,主要包括四種模式:?Simple Service??Web Service Proxy??Bridge?

Validator?Web Service Proxy Pattern?正是本文中提到的?WebService Proxy?這里有關于它的更多介紹。

三、Web Service Proxy?實現

1WSProxy?的實現機制


WSProxy?實現機制的組件圖如下所示
MuleWSProxy??3?個組件組成:
(1) MessageSource
????
它通過?MessageLister?接收或者產生?MuleMessage?,本實例中采用?DefaultInboundEndpoint?作為MessageSource?,并通過

socket?接收?SOAP消息。這里有關于?MessageSource?的介紹。
(2) AbstractProxyRequestProcessor
????
負責處理MuleEvent,重寫WSDL地址。其實現類有兩個,分別是:?StaticWsdlProxyRequestProcessor?

DynamicWsdlProxyRequestProcessor?,本實例中采用的是?DynamicWsdlProxyRequestProcessor?
(3) OutboundEndpoint
????
負責分發和接收SOAP消息。

2WSProxy?運行期數據流圖

?????
運行期數據流圖如下所示

運行期數據流:
(1)?DefaultInboundEndpoint?中,?HttpServerConnection?負責在?http://localhost:8080?上接收?SOAP?請求,

MessageProcessorChain?是一系列的?MessageProcessor?,對?MuleEvent?進行處理,主要包括:

ExceptionHandlingMessageProcessor??InboundEndpointMimeTypeCheckingMessageProcessor?

InboundEndpointPropertyMessageProcessor??InboundLoggingMessageProcessor?MessageProcessor?
(2)?MessageProcessorChain?中,通過?DynamicWsdlProxyRequestProcessor?重寫?WSDL?訪問地址,即將?proxy WSDL?地址重新為

remote WSDL?地址。
(3)?DefaultOutboundEndpoint?中,主要通過?HttpClientMessageDispatcher?調用?HttpClient?發送和接收SOAP?消息。

Web Service Proxy

? ? Web Service Proxy用來將客戶端的WS請求直接轉發至相應的遠程WS服務端處理,并返回處理結果。Mule本身不做任何處理。

2.1 配置方式1

  • 示例配置

<flow?name="local2remote-ws">

????<http:inbound-endpoint?keep-alive="false"?address="http://localhost:65000"

????????encoding="UTF-8"?disableTransportTransformer="false"?exchange-pattern="request-response"?doc:name="HTTP"

????????doc:description=""?/>

????<http:outbound-endpoint?method="GET"?keep-alive="false"

????????address="http://localhost:5050#[header:INBOUND:http.request]"?responseTimeout="10000"?encoding="UTF-8"

????????disableTransportTransformer="false"?followRedirects="false"?exchange-pattern="request-response"

????????doc:name="HTTP"?doc:description=""?/>

</?flow?>

??

  • 說明
  • 注意?outbound-endpoint??address?參數中的表達式。
  • 測試方法
  • 瀏覽器中通過“?http://localhost:65000/webservice/EchoService?wsdl?”(將內容復制,保存為?*.wsdl?),然后使用?SoapUI?測試。
  • 2.2 配置方式2
  • 示例配置
  • <pattern:web-service-proxy?name="ws-proxy"?inboundAddress=http://localhost:65082/services/Echo2
  • outboundAddress="http://localhost:65082/services/Echo1?method=echo">

</pattern:web-service-proxy>

?

?

?

?

?

?

?

  • 說明

?

Mule?為這種常見的場景提供了現成的模式,以簡化配置。

?

?

?

?

  • 測試方法

?

通過“?http://localhost:65082/services/Echo2?wsdl?”獲取?wsdl?文件,然后使用?SoapUI?測試。2.3 配置方式3

?<ws:proxy name="mule-Ws-Proxy" inboundAddress="http://localhost:8080/services/WeatherWS"?
?????????????? outboundAddress="
http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx"/>

?

?

?

?

?

?

?

說明

?

?

Mule?為這種常見的場景提供了現成的模式,以簡化配置。

?

?

?

?

  • 測試方法

?

通過“?http://localhost:8080/services/WeatherWS?wsdl?”獲取?wsdl?文件,然后使用?SoapUI?測試。??完整的mule配置文件:

?

Xml代碼
  • <?xml?version="1.0"?encoding="UTF-8"?>??
  • <mule?xmlns="http://www.mulesoft.org/schema/mule/core"??
  • ???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
  • ???????xmlns:spring="http://www.springframework.org/schema/beans"??
  • ???????xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"??
  • ???????xmlns:ws="http://www.mulesoft.org/schema/mule/ws"??
  • ???????xmlns:http="http://www.mulesoft.org/schema/mule/http"??
  • ???????xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"??
  • ????xsi:schemaLocation="??
  • ???????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/ws?http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd??
  • ???????http://www.mulesoft.org/schema/mule/http?http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd??
  • ???????http://www.mulesoft.org/schema/mule/pattern?http://www.mulesoft.org/schema/mule/pattern/current/mule-pattern.xsd??
  • ???????http://www.mulesoft.org/schema/mule/stdio?http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd">??
  • ??
  • ??
  • <!--?
  • <flow?name="local2remote-ws">??
  • ?????<http:inbound-endpoint?keep-alive="false"?address="http://localhost:65000"??
  • ????????encoding="UTF-8"?disableTransportTransformer="false"?exchange-pattern="request-response"/>??
  • ????<http:outbound-endpoint?method="GET"?keep-alive="false"??
  • ????????address="http://webservice.webxml.com.cn#[header:INBOUND:http.request]"?responseTimeout="10000"?encoding="UTF-8"??
  • ????????disableTransportTransformer="false"?followRedirects="false"?exchange-pattern="request-response"?/>??
  • </flow>
  • -->
  • <flow name="local2remote-ws">
    ??<http:inbound-endpoint keep-alive="false"
    ???address="http://localhost:8088/MSPGS/MPService" encoding="UTF-8"
    ???disableTransportTransformer="false" exchange-pattern="request-response" />
    ??<http:outbound-endpoint method="GET"
    ???keep-alive="false"
    ???address="http://10.10.31.25/MSPGWebPub/MSPGS/MPService.svc"
    ???responseTimeout="10000" encoding="UTF-8" disableTransportTransformer="false"
    ???followRedirects="false" exchange-pattern="request-response" />
    ?</flow>??
  • ??
  • ??
  • ?<pattern:web-service-proxy?name="ws-proxy-pattern"?inboundAddress="http://localhost:65081/services/getRegionDataset"??
  • ????????????outboundAddress="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?op=getRegionDataset">??
  • ?</pattern:web-service-proxy>??
  • ??
  • ?<ws:proxy?name="mule-Ws-Proxy"?inboundAddress="http://localhost:8080/services/WeatherWS"???
  • ???????????????outboundAddress="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx"/>??
  • </mule>??
  • ?測試:

    Java代碼
  • public?class?MuleProxyMain?{??
  • ??????
  • ????public?static?void?main(String[]?args)??{??
  • ????????try?{??
  • ????????????System.setProperty("java.endorsed.dirs","D:/android-workspace/MuleProxy/libs/endorsed");??
  • ????????????System.out.println(System.getProperty("java.endorsed.dirs"));??
  • ????????????String?configFile?=?"mule-ws-conf-service.xml";??
  • ????????????String[]?configFileArr?=?new?String[]?{configFile?};??
  • ????????????MuleContextFactory?muleContextFactory?=?new?DefaultMuleContextFactory();??
  • ????????????MuleContext?muleContext?=?muleContextFactory??
  • ????????????????????.createMuleContext(new?SpringXmlConfigurationBuilder(configFileArr));??
  • ????????????muleContext.start();??
  • ????????}?catch?(Exception?e)?{??
  • ????????????e.printStackTrace();??
  • ????????}??
  • ??????
  • ????}??
  • ?????
  • ??
  • }??
  • ?

    總結

    以上是生活随笔為你收集整理的Mule ESB 学习笔记(11)Web Service Proxy(这里是一个可以正常运行的例子)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。