使用Axis2搭建WebService环境(一)

一、下载最新的(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,结果如下:



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值