今天做了一个Axis2 Module的例子(官网介绍),感觉很简单,但也很实用这里和大家分享一下
步骤:
1.首先要写一个Module的实现类
这里我写了一个和官网上的不太一样,但也差不多
package userguide.loggingmodule;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.modules.Module;
import org.apache.neethi.Assertion;
/**
*
* @author cnchenhl
* Jun 15, 2011
*/
public class LoggingModule implements Module {
/**
* Initialize the module
*/
public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
}
/**
* End of module processing
*/
public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
}
public void engageNotify(AxisDescription axisDescription) throws AxisFault {
}
public boolean canSupportAssertion(Assertion assertion) {
return false;
}
@Override
public void applyPolicy(org.apache.neethi.Policy arg0, AxisDescription arg1) throws AxisFault {
}
}
2.然后就是也Hander,我们也实现它
package userguide.loggingmodule;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
* @author cnchenhl
* Jun 15, 2011
*/
public class LogHandler extends AbstractHandler implements Handler {
private static final Log log = LogFactory.getLog(LogHandler.class);
private String name;
public String getName() {
return name;
}
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
log.info(msgContext.getEnvelope().toString());
return InvocationResponse.CONTINUE;
}
public void revoke(MessageContext msgContext) {
log.info(msgContext.getEnvelope().toString());
}
public void setName(String name) {
this.name = name;
}
}
3.下面做module.xml
<module name="logging" class="userguide.loggingmodule.LoggingModule">
<InFlow>
<handler name="InFlowLogHandler" class="userguide.loggingmodule.LogHandler">
<order phase="loggingPhase" />
</handler>
</InFlow>
<OutFlow>
<handler name="OutFlowLogHandler" class="userguide.loggingmodule.LogHandler">
<order phase="loggingPhase"/>
</handler>
</OutFlow>
<OutFaultFlow>
<handler name="FaultOutFlowLogHandler" class="userguide.loggingmodule.LogHandler">
<order phase="loggingPhase"/>
</handler>
</OutFaultFlow>
<InFaultFlow>
<handler name="FaultInFlowLogHandler" class="userguide.loggingmodule.LogHandler">
<order phase="loggingPhase"/>
</handler>
</InFaultFlow>
</module>
4.修改axis2.xml
<phaseOrder type="InFlow">
<phase name="loggingPhase"/>
<phaseOrder type="OutFlow">
<phase name="loggingPhase"/>
........
5.修改service.xml
加上<module ref="logging"/>
6.打包
基本的将上面的类编译成class,然后将module.xml放到META-INF下面 打包成jar,然后改后缀名为mar
7.发布
嘿嘿这个发布很简单,放到module文件夹下即可。
好了以上就是开发过程
有什么问题给我留言
分享到:
相关推荐
对Eclipse4.3(Kepler server release2)版本配置Axis2-1.6.2,开发webservice服务接口,里面是自己配置过程中的总结和一些相关的插件压缩包,还有一份word文档是我操作的一些总结,希望对大家有所帮助。
axis2详细配置过程,以及客户端的生成
myEclipse 8.0 配置axis2的工具jar 将解压得到的5个jar放在myEclipse 安装包的dropins下
axis教程 axis教程 axis教程 axis教程 axis教程
Spring集成AXIS2的Web_service配置方法
详细说明如果在eclipse 3.2.2上配置Axis2开发环境
myeclips8.5配置axis2的完整jar包
Eclipse中配置Axis2需要用到的jar包
myeclipse下AXIS2配置webservice详细文档。
axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例
axis2的安装配置以及axis2 eclipse plugin安装
axis2-adb-1.5.4.jar axis2-adb-codegen-1.5.4.jar axis2-codegen-1.5.4.jar axis2-corba-1.5.4.jar axis2-fastinfoset-1.5.4.jar axis2-java2wsdl-1.5.4.jar axis2-jaxbri-1.5.4.jar axis2-jaxws-1.5.4.jar axis2-...
Axis2 配置与简单运用
axis2客户端调用axis1服务接口 调用方式 使用RPC方式调用WebService,为了防止冲突可以增加 // 与weblogic的lib冲突配置 System.setProperty("javax.xml.stream.XMLInputFactory", ...
axis2在tomcat上配置的必要工具
Axis2 WebService(配置、发布、调用)
axis2 webservice 服务端jar包: -->axis2-kernel-1.6.1.jar -->axis2-spring-1.6.1.jar -->axis2-transport-http-1.6.1.jar -->XmlSchema-1.4.7.jar -->wsdl4j-1.6.2.jar -->axiom-api-1.2.12.jar -->axiom...
axis2-1.6.2.zip, windows axis2工具,根据 WSDL生成java文件。 1、axis2客户端下载地址:http://mirror.esocc.com/apache//axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip; 2、下载解压在D:\Work_Program_...
axis配置(axis详细配置),网上找的,应该没有什么问题。。
在MyEclipse环境下配置Axis2的详细步骤与web service简单程序应用 适合初学者使用!!