以一个实例看Mule3.0中的Flow

flow是mule3.0中新增的一个处理消息的形式,它是区别与之前版本的service的,但又可以以不同的方式来处理service中能够处理的消息。下面以Mule3.0中的Echo Example来学习一下关于flow的知识,flow里面可以配置入站,出站,可以放component等等的东西,另外flow是不知道如何处理Web服务调用的,所以我们一般需要一个像CXF这样的过滤器,因为CXF中有内置的支持去理解GET请求,CXF使用如下的语法:

http://主机/服务/方法/参数名/参数值
如下面的这个例子使用的是:
另外在Flow中配置的CXF必须要指定他的serviceClass,在service中配置是不需要的是因为service中可以自动的发现component,但是flow目前还不支持所以必须要配上之后才可以找到component。
还有一个地方就是入站中设置的入口时一个WS的url地址,如果使用了exchange-pattern =“request-response”,则它将返回给我们这个URL。
mule的配置文件如下:
    <description>
        This config builds a JAX-WS service with CXF.
       
        We use a "serviceClass" which is a JAX-WS interface we've defined. It allows us
        to ensure that the WSDL is only generated for the "echo" method (as opposed
        to all the other methods on the EchoComponent). This keeps our WSDL nice
        in clean - but it is not required.
        To invoke the EchoUMO hit the following URL -
            http://localhost:65082/services/EchoUMO/echo/text/hello
       
        To view the WSDL for the EchoUMO service go to -
            http://localhost:65082/services/EchoUMO?wsdl
    </description>
    <flow name="EchoFlow">
        <inbound-endpoint address=" http://localhost:65082/services/EchoUMO" exchange-pattern="request-response"/>
        <cxf:jaxws-service serviceClass="org.mule.example.echo.Echo"/><!--这里是必须要配置的然后才能找到下面的component-->
        <component>
            <singleton-object class="org.mule.example.echo.Echo" />
        </component>
    </flow>
   
</mule>
 
 
Echo类是要根据CXF的语法规则发布成WS的,其实现形式如下:
/*
 * $Id: Echo.java 19191 2010-08-25 21:05:23Z tcarlson $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */
package org.mule.example.echo;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService
public class Echo
{
    @WebResult(name="text")
    public String echo(@WebParam(name="text") String string)
    {
        return string;
    }
}
 
以上类的形式是说明该类被发布成了WebService的形式。
本文就想以最简单的形式来说明一下mule3.0中的flow的用法。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值