mule2.2.x架构(四)示例学习StockQuote

mule2.2.x架构(四)示例学习StockQuote

所有的示例文档
http://www.mulesoft.org/display/MULE2INTRO/Examples

本示例参考地址
http://www.mulesoft.org/display/MULE2INTRO/Stock+Quote+Example

3 简单示例StockQuote
3.1 标准IO输入,输出到VM
配置文件stdio-config.xml
<!-- 配置文件中载入提示欢迎信息 -->
<stdio:connector name="SystemStreamConnector"
promptMessageCode="2"
resourceBundle="stockquote.messages.stockquote-messages"
messageDelayTime="1000"/>
<model name="Sample">
<service name="Console I/O">
<inbound>
<!-- 标注IO输入 -->
<stdio:inbound-endpoint system="IN" synchronous="true"/>
</inbound>
<outbound>
<chaining-router>
<!-- 链式输出:输出到VM内部queen -->
<vm:outbound-endpoint path="stockquote"/>
<!-- 链式输出:标准系统输出 -->
<stdio:outbound-endpoint system="OUT"/>
</chaining-router>
</outbound>
</service>
</model>
单独启动这个配置文件,要报错,因为找不到对应的VM stockquote,这个配置文件要和后面的文件配合启动,命令行启动的话:
"%MULE_BASE%\bin\mule.bat" -config "stdio-config.xml,stockquote-rest-config.xml"
"%MULE_BASE%\bin\mule.bat" -config "stdio-config.xml,stockquote-wsdl-config.xml"
"%MULE_BASE%\bin\mule.bat" -config "stdio-config.xml,stockquote-soap-config.xml"
eclipse启动的话,要用Run Configuration---->Configuration Files-----Add
添加多个xml配置文件,然后再Run就OK了。

3.2 输出到REST的服务器
配置文件stockquote-rest-config.xml
<!-- 读取配置文件proxy.properties,配置访问外网的HTTP代理 -->
<context:property-placeholder location="stockquote/proxy.properties"/>
<http:connector name="HttpConnector"
proxyHostname="${proxyHostname}"
proxyPassword="${proxyPassword}"
proxyPort="${proxyPort}"
proxyUsername="${proxyUsername}"/>
<xm:xml-to-object-transformer name="XmlToObject"/>
<xml-entity-decoder-transformer name="XmlDecoder"/>
<xm:xslt-transformer name="Xslt" xsl-file="stockquote/xsl/rest-stock.xsl"/>
<object-to-string-transformer name="ToString"/>
<model name="Sample-Rest">
<service name="HTTPPostSample">
<inbound>
<!-- 结合上面的stdio-config.xml输出的stockquote,这里接收信息 -->
<vm:inbound-endpoint path="stockquote"
responseTransformer-refs="ToString XmlDecoder Xslt XmlToObject" synchronous="true"/>
</inbound>
<http:rest-service-component
serviceUrl="http://www.webservicex.net/stockquote.asmx/GetQuote"
httpMethod="POST">
<http:payloadParameterName value="symbol"/>
</http:rest-service-component>
</service>
</model>
最后的发送向一个REST服务,这个服务是外网的:
http://www.webservicex.net/stockquote.asmx/GetQuote

3.3 发送到SOAP服务的WS上
配置文件stockquote-soap-config.xml,和上面的rest的核心区别就在于最后的发送配置
<outbound>
<pass-through-router>
<axis:outbound-endpoint
address="http://www.webservicex.net/stockquote.asmx?method=GetQuote"
soapAction="#[methodNamespace]#[method]">
<axis:soap-method method="qname{GetQuote:http://www.webserviceX.NET/}">
<axis:soap-parameter parameter="symbol" type="string" mode="IN"/>
<axis:soap-parameter parameter="GetQuoteResult" type="string" mode="OUT"/>
</axis:soap-method>
</axis:outbound-endpoint>
</pass-through-router>
</outbound>

3.4 发送到wsdl
配置文件stockquote-wsdl-config.xml,和前面的核心区别如下
<outbound>
<pass-through-router>
<outbound-endpoint
address="wsdl-cxf:http://www.webservicex.net/stockquote.asmx? WSDL&method=GetQuote" />
</pass-through-router>
</outbound>
但是3.1+3.2;3.1+3.2我都测试成功了,就是3.1+3.3测试失败。但是明白了这个示例的意思,以后可以自己启动一些WS的服务来详细测试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值