使用axis2开发webservices并打包到tomcat
1. 写service类
package com.datatrans.demo; public class HelloServiceNew { public String sayHelloNew(){ return "hello"; } public String sayHelloToPersonNew(String name){ if(name==null){ name = "nobody"; } return "hello,"+name; } public void updateData(String data){ System.out.println(data+"更新!"); } }
2.写services.xml文件
<?xml version="1.0" encoding="UTF-8"?> <service name="HelloServiceNew"> <description> web </description> <parameter name="ServiceClass"> com.datatrans.demo.HelloServiceNew </parameter> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"> </messageReceiver> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"> </messageReceiver> </messageReceivers> </service>
3.编译java类
cmd进入Java类的目录,为了编译后class文件包含包目录,要使用-d选项
javac -d . HelloServiceNew.java
4.打成aar包
把class文件和xml文件放入以下目录结构
G:\temp\ws\com...\HelloServiceNew.class
G:\temp\ws\META-INF\services.xml
执行jar cvf ws.aar .打包成功ws.aar
5.最后,把aar包放入到...\tomcat\webapps\axis2\WEB-INF\services目录下,就可以使用webservices了
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。