---
title: "基于axis2的ws构建示例-服务端"
author: "阳光小菜鸟"
date: "2009-11-04T13:55:51Z"
tags: ["Apache", "Web", "WebService", "XML", "应用服务器"]
slug: "axis2-ws"
draft: false
lastmod: "2009-11-04T13:59:13Z"
id: 509949
url: "https://shiningwu.iteye.com/blog/509949"
---

1）、新建WEB工程axis2\_server，该web应用项目通过下面系列配置，达到向外提供Webservice服务的目的。 2）、访问axis2.war的内部文件，如下图所示： \[img]http://dl.iteye.com/upload/picture/pic/48507/24dc751e-f763-3c2d-b71b-be524c64a43d.png\[/img] 将axis2文件夹下上图勾选内容复制到工程axis2\_server对应位置，如下图所示： \[img]http://dl.iteye.com/upload/picture/pic/48509/df07079e-dbb6-379c-b5ef-8264d213124e.png\[/img] 3）、编写一个简单的java类,该类最终会部署作为Webservice服务方法。 \[code="java"] package zzvcom.ws; public class SampleServerImpl implements SampleServer { public String echo(String s) { String backValue="hello,"+s; return backValue; } } \[/code] 4）、在SRC下创建META-INF文件夹，并在下面建立文件名为services.xml的文件，添加如下内容： \[code="java"] zzvcom.ws.SampleServerImpl \[/code] 该文件内容为axis2服务的配置文件，注意最后一项“zzvcom.webservice.SampleServerImpl”为作为外部服务的类名。 5）、将src下的META-INF文件利用以下命令打包： jar –cvf SampleServer.aar META-INF. 打包生成的SampleServer.aar结构如下图： \[img]http://dl.iteye.com/upload/picture/pic/48511/1453db92-3b2d-3b49-ba21-93dd1f84aac4.png\[/img] 将打包生成的SampleServer.aar文件放入到WebRoot/WEB-INF/services目录下 6）、在web.xml中注册axis2相关信息： \[code="java"] Apache-Axis2 AxisServlet org.apache.axis2.transport.http.AxisServlet 1 AxisAdminServlet org.apache.axis2.webapp.AxisAdminServlet AxisServlet /servlet/AxisServlet AxisServlet \*.jws AxisServlet /services/* AxisAdminServlet /axis2-admin/* index.jsp \[/code] 将以上完整项目部署在Tomcat服务器下，通过以下访问地址： http://localhost:8080/axis2\_server/services/listServices 可以访问到建立好的Webservice服务描述