一、下载最新的(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 @R_476_4045@ion 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,结果如下:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。