打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
以一个实例看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的用法。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成
webservice原理及基于cxf开发的基本流程
WebService
java开发webservice的几种方式
Web Service 那点事儿(1)
CXF WebService 开发指南、技术文档
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服