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了