一、下载最新的(2012年)axis2-1.6.2-war,阅读README.txt,如下可以创建一个新的Service
___________________
Deploying
===================
To deploy a new Web service in Axis2 the following three steps must
be performed:
1) Create the Web service implementation class, supporting classes
and the services.xml file,
2) Archive the class files into a jar with the services.xml file in
the META-INF directory
3) Drop the jar file to the $AXIS2_HOME/WEB-INF/services directory
where $AXIS2_HOME represents the install directory of your Axis2
runtime. (In the case of a servelet container this would be the
"axis2" directory inside "webapps".)
To verify the deployment please go to http://<yourip>:<port>/axis2/ and
follow the "Services" Link.
For more information please refer to the User's Guide.
二、运行axis2-1.6.2-war,使用的servlet容器为tomcat6.0.41
复制axis2-1.6.2-war文件夹到%TOMCAT_HOME%/webapps,启动tomcat,访问url(http://localhost:8080/axis2/services/listServices),可以看到Axis2自带的WebService:Version
三、解压缩axis2-1.6.2-war/axis2.war,仿照axis2\WEB-INF\services\version-1.6.2.aar,写自己的WebService并打成jar,其实aar文件可可以理解为jar
写一个简单的类如下:
package com.test;
public class HelloWorld {
public String sayHello() {
return "saying hellooooooooooooo";
}
}
Ant打包文件如下:
<project name="helloworldservice" basedir="." default="deploy">
<property name="src.dir" value="src">
</property>
<property name="build.dir" value="${basedir}/build">
</property>
<path id="build.classpath">
</path>
<target name="init">
<delete dir="${build.dir}">
</delete>
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dir}/classes" />
<mkdir dir="${build.dir}/jar" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${build.dir}\classes">
<classpath refid="build.classpath">
</classpath>
</javac>
</target>
<target name="makejar" depends="compile">
<jar destfile="${build.dir}\jar\${ant.project.name}.jar">
<fileset dir="${build.dir}/classes">
<include name="**/*.class"/>
</fileset>
<metainf dir="${basedir}">
<include name="services.xml"/>
</metainf>
</jar>
</target>
<target name="deploy" depends="makejar">
<copy file="${build.dir}/jar/${ant.project.name}.jar" todir="D:\wsc\software\apache-tomcat-6.0.41\webapps\axis2\WEB-INF\services"></copy>
</target>
</project>
运行deploy后,不用重启tomcat,访问Url:http://localhost:8080/axis2/services/listServices,结果如下: