一、准备
(1)JDK 1.8,Tomcat9.0,MyEclipse2016
(2)Axis2:https://axis.apache.org/axis2/java/core/download.html
二、环境配置
2.1 MyEclipse Axis2环境配置:解压axis2-eclipse-service-plugin和axis2-eclipse-codegen-plugin,把得到的两个jar包放到%MyEclipse安装目录%\dropins,重启MyEclipse;
2.2 发布Axis2:解压axis2-1.7.6-war.zip得到axis.war并将其放到%Tomcat安装目录%/webapps下,然后启动Tomcat在浏览器中输入http://localhost:8080/axis2/,出现如下图所示则配置成功
三、发布Axis2
3.1在MyEclipse中new一个WebProject,命名WebService,然后编写一段服务器代码如下:
package org.web.service;
public class HelloWorldService {
public String sayHello(String name) {
return "Hello,"+name;
}
}
3.2 File>>New>>Other>>Axis2 Wizards>>Axis2 Service Archiver,双击后选择WebService项目编译后的class所在路径
next>>选中Skip WSDL,next>>什么都不填>>next>>选中Generate the service xml automatically,next>>
点击next>>填写output location(如:%WebService项目地址%/src),点击finish,到MyEclipse中刷新项目,出现my_service.aar文件
3.3 复制此aar文件到%tomcat安装目录%/webapps/axis2/WEB-INF/services下。重新启动tomcat,在浏览器中输入http://localhost:8080/axis2/services/HelloWorldService?wsdl,出现下图说明发布成功
或者输入http://localhost:8080/axis2/services/listServices,出现下图说明发布成功
网友评论