mule学习笔记(八):代理方式调用服务

这篇博客介绍了如何使用Mule ESB进行服务代理,以调用远程WebService。通过三种不同的配置方式,成功实现从`http://localhost:8880`, `http://localhost:8881`, 到 `http://localhost:8882` 的代理服务,调用`http://webservice.webxml.com.cn`的天气服务。这些配置包括了web-service-proxy和ws:proxy元素的使用。" 133454921,19673918,数据库管理系统:概念、功能与编程实现,"['数据库', '编程', 'SQL']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
xmlns:ws="http://www.mulesoft.org/schema/mule/ws"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/3.1/mule-ws.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/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">
      <!--  远程调用发布的webservice方法一
      调用结果:不报错,浏览器输出“Directory Listing Denied This Virtual Directory does not allow contents to be listed.”-->
 <!--       <flow name="HttpProxyService" doc:name="HttpProxyService">
         <http:inbound-endpoint exchange-pattern="request-response" encoding="UTF-8" address="http://localhost:8880" doc:name="HTTP"/>
         <http:outbound-endpoint exchange-pattern="request-response" encoding="UTF-8" address="http://webservice.webxml.com.cn?op=getWeather" doc:name="HTTP" method="GET"/>
         </flow>
  -->  
         <!-- 远程调用发布的webservice方法二
             调用结果:success!
             其中"?op=getWeather"指明调用方法名。
             参考资料:http://www.mulesoft.org/documentation/display/34X/Web+Service+Proxy+Pattern-->
      <pattern:web-service-proxy name="muleProxy" inboundAddress="http://localhost:8881"
      outboundAddress="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?op=getWeather">
      </pattern:web-service-proxy>
 
     
      <!-- 远程调用发布的webservice方法三
                 调用结果:success!-->
 <!--       <ws:proxy name="mule-Ws-Proxy" inboundAddress="http://localhost:8882"
        outboundAddress="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?op=getWeather" />
  -->
      
      
    
       
</mule>


<!--使用说明:这是一个服务代理的例子,被代理的服务是“http://localhost:8888”,是一个已经发布的web Service(他可以是发布在本地服务器上的服务
,也可以是发布在远程服务器上的服务,总之,只要是义发布的web Service就可以),本文中是发布在Standalone server中(路径:D:\mule-standalone-3.4.0\apps\mule-example-hello-3.4.0),
服务“http://localhost:8880”是发布在esb平台上的代理服务。
参考资料:http://www.360doc.com/content/11/0322/15/2795334_103545455.shtml
目的:通过esb平台上的代理服务来访问第三方web Service-->

<!-- 说明2:原有例子采用方法一,outbound-endpoint address为发布在Standalone serve中的服务访问地址(http://localhost:8888)。使用时需要先启动mule Standalone serve。
现修改为多种配置方法代理远程服务。方法2、3需要增加对应namespace(现已全部加入),否则出现not bound错误。
参考资料:http://www.oschina.net/question/1467716_146853?sort=time -->

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值