以一个实例看Mule3.0中的Flow
2012-07-13 14:26
141 查看
flow是mule3.0中新增的一个处理消息的形式,它是区别与之前版本的service的,但又可以以不同的方式来处理service中能够处理的消息。下面以Mule3.0中的Echo Example来学习一下关于flow的知识,flow里面可以配置入站,出站,可以放component等等的东西,另外flow是不知道如何处理Web服务调用的,所以我们一般需要一个像CXF这样的过滤器,因为CXF中有内置的支持去理解GET请求,CXF使用如下的语法:
http://主机/服务/方法/参数名/参数值 如下面的这个例子使用的是:
http://localhost:65082/services/EchoUMO/echo/text/hello
另外在Flow中配置的CXF必须要指定他的serviceClass,在service中配置是不需要的是因为service中可以自动的发现component,但是flow目前还不支持所以必须要配上之后才可以找到component。
还有一个地方就是入站中设置的入口时一个WS的url地址,如果使用了exchange-pattern =“request-response”,则它将返回给我们这个URL。
mule的配置文件如下:
<?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:cxf="http://www.mulesoft.org/schema/mule/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/cxf
http://www.mulesoft.org/schema/mule/cxf/3.0/mule-cxf.xsd">
<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的用法。
http://主机/服务/方法/参数名/参数值 如下面的这个例子使用的是:
http://localhost:65082/services/EchoUMO/echo/text/hello
另外在Flow中配置的CXF必须要指定他的serviceClass,在service中配置是不需要的是因为service中可以自动的发现component,但是flow目前还不支持所以必须要配上之后才可以找到component。
还有一个地方就是入站中设置的入口时一个WS的url地址,如果使用了exchange-pattern =“request-response”,则它将返回给我们这个URL。
mule的配置文件如下:
<?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:cxf="http://www.mulesoft.org/schema/mule/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/cxf
http://www.mulesoft.org/schema/mule/cxf/3.0/mule-cxf.xsd">
<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的用法。
相关文章推荐
- 一个AgileFlow的流程定义实例
- 一个AgileFlow的流程定义实例
- 一个AgileFlow的流程定义实例
- caffe 入门实例2 如何写一个模型
- 网络互联OSI参考模型网络互联设备网络拓扑结构网络互联方式网络连接的一个实例
- 一个真实的实例: Java程序员的成长经历
- thrift实现一个C++实例遇到的问题
- Jmeter---一个简单的性能测试实例(聚合报告)
- (C#)一个WCF简单实例
- jtable 加入按钮等,一个实例
- 用内存映射文件实现应用程序只运行一个实例
- Python中使用wxPython开发的一个简易笔记本程序实例
- C# WinForm 只运行一个程序实例
- 小vimer的心得+求primer一个实例问题解答
- 一个很好的关于Platform Builder的开发实例
- synchronized用法的一个实例
- SpringMVC-(1)一个简单的实例demo及讲解
- 批量读入一个文件夹中文件的数据操作实例
- 一个JS内存泄露实例分析
- 一个完整的maven配置selenium webdriver工程实例(三)