axis2的下载与安装
在使用之前当然需要先安装axis2相关的服务 ,安装axis2服务之前当然要先下载相关安装文件。下载地址:
http://axis.apache.org/axis2/java/core/download.cgi
可以下载如下两个zip包: axis2-1.5.4-bin.zip axis2-1.5.4-war.zip,其中 axis2-1.5.4-bin.zip文件中包含了Axis2中所有的jar文件, axis2-1.5.4-war.zip文件用于将WebService发布到Web容器中。将axis2-1.5.4-war.zip文件解压到相应的目录,将目录中的axis2.war文件放到Tomcat安装目录\webapps目录中,并启动Tomcat,在浏览器地址栏中输入如下的URL: http://localhost:8080/axis2/,如看到axis2的主页面则安装成功。
好啦。安装完毕之后就开始我们的webservice了
1 先新建一个web project 名称为HelloWorldTest
然后再建一个服务类 HelloWorld
package com.hjy;
public class HelloWorld {
public String getHello(String s){
return "hello"+s;
}
public String getWorld(String s){
return "world"+s;
}
public String getHelloWorld(){
return "helloWrold";
}
}
2 修改web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>HelloWorldTest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>