mule2.2.x架构(八)部署到WEB项目

mule2.2.x架构(八)部署到WEB项目

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

本来想参考webapp的,结果没有成功,于是在原来的例子基础上一个一个自己慢慢集成到WEB中试试。
在web.xml中配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Mule</display-name>
<description>MuleWebAppSamples</description>
<!-- 装载的配置文件 -->
<context-param>
   <param-name>org.mule.config</param-name>
   <param-value>
    echo/echo-axis-config.xml,
    echo/echo-cxf-config.xml
        </param-value>
</context-param>
<!-- 容器的监听器 -->
<listener>
   <listener-class>
    org.mule.config.builders.MuleXmlBuilderContextListener
   </listener-class>
</listener>
<welcome-file-list>
   <welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
里面的两个配置文件就是使用的原来项目中的,如果两个都要一起启动,那么后面有提到service和model名字需要做修改,不然要冲突。也可以一个一个启动。
另外我在pom.xml中引入了一下的包:
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transports</artifactId>
<version>2.2.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule</artifactId>
<version>2.2.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.script</groupId>
<artifactId>jython-engine</artifactId>
<version>1.1jdk14</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-builders</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-servlet</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-management</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-stdio</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-vm</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-client</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-axis</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-cxf</artifactId>
<version>2.2.1</version>
</dependency>

echo/echo-axis-config.xml
调用方法
http://localhost:65081/services/EchoUMO?method=echo&param=iamcarl
返回
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<echoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<echoReturn xsi:type="xsd:string">iamcarl</echoReturn>
</echoResponse>
</soapenv:Body>
</soapenv:Envelope>
WSDL文件路径http://localhost:65081/services/EchoUMO?wsdl,嘿嘿,用刚刚正的xfire的client来调用一下试试。
核心调用程序如下:
Client client = new Client(new URL(
"http://localhost:65081/services/EchoUMO?wsdl"));
Object[] results = client.invoke("echo", new Object[] { "hello mule!" });
System.out.println("results:" + results[0]);
}
打印出了hello mule

echo/echo-cxf-config.xml
拷贝了echo-cxf-config.xml后,需要修改axis和cxf里面的 model名称和service名称分别如下:
AXIS: <model name="echoAxis">
<service name="EchoUMOAxis">
CXF: <model name="echoCxf">
<service name="EchoUMOCxf">
修改了以上名字后,Axis的调用的service名字就改为了echoAxis了,需要访问
http://localhost:65081/services/EchoUMOAxis?method=echo&param=iamcarl

http://localhost:65081/services/EchoUMOAxis?wsdl

调用CXF方法不受这个名字的影响,而是在address中决定的,为了看起来统一方便,我将address的名字做了修改,
加上了Cxf的后缀
<cxf:inbound-endpoint address="http://localhost:65082/services/EchoUMOCxf"
serviceClass="com.sillycat.easymule.echo.Echo"/>
那么访问CXF的链接就变为
http://host/service/OPERATION/PARAM_NAME/PARAM_VALUE
http://localhost:65082/services/EchoUMOCxf/echo/text/hello
返回
<soap:Envelope>
<soap:Body>
<ns2:echoResponse>
<text>hello</text>
</ns2:echoResponse>
</soap:Body>
</soap:Envelope>
WSDL文件路径:http://localhost:65082/services/EchoUMOCxf?wsdl,用xfire的client访问一下,发现取不到返回值:(,不过我对cxf也不熟悉。所以这里也不去查找了。

你可能感兴趣的:(Web,xml,python,activemq,jython)