一、AXIS2简介
AXIS2是WebService/SOAP/WSDL的引擎,是Appache AXIS 1.x的衍生版。支持更强的模块化、更高的灵活性、更有效地体系结构,可以更容易地与其他Web Service 服务标准与协议(如 WS-Security、WS-ReliableMessaging 等)结合。具有以下特点:
- 采用AXIOM的XML处理模型,支持灵活定义对象模型。
- 支持不同的消息交换模式:In-Only、Robust-In和In-Out 。In-Only消息交换模式只有SOAP请求,而不需要应答;Robust-In消息交换模式发送SOAP请求,只有在出错的情况下才返回应答;In-Out消息交换模式总是存在SOAP请求和应答。
- 提供阻塞与非阻塞的API。
- 支持内置的服务寻址(WebService-Addressing)。
- 灵活的数据绑定与Web Service发布方式:支持POJO(Plain Old Java Object)、AXIOM、XMLBeans、JiBX、JAXB 2.0等。
- 全新的部署模型,支持热部署、热更新。
- 支持HTTP、SMTP、JMS、TCP传输协议。
- 支持REST(Representational State Transfer)。
二、AXIS2的下载与部署
1.首先,在客户机安装appache tomcat以及jdk基础环境。
2.在http://axis.apache.org/axis2/java/core/下载AXIS2的压缩包
目前,AXIS2的最新版本是1.6.3(2015.6.27)。本文下载1.6.2(2012.4.17)版本。
下载列表:
axis2-1.6.2-bin.zip AXIS2完整版,支持WS-Addressing与SOAP-Moniter
axis2-1.6.2-war.zip AXIS2 Web容器部署版本
3.解压axis2-1.6.2-war.zip文件,然后将axis2.war文件拷贝到<Tomcat安装目录>\webapps目录,启动Tomcat,在浏览器地址栏输入AXIS2的URL(http://localhost:8080/axis2/),axis2.war会自动解压缩,如果,AXIS2的主页面则表示加载成功。
三、编写与发布WebService
(1)POJO方式发布(无需任何设置 )
在AXIS2中无需任何设置,可以让简单的POJO发布成Web Service。其中POJO的public方法会发布成为Web Service方法。
public class AXISHelloService { public String sayHello(){ return "Hello AXIS"; } public String sayHelloToPerson(String name){ if(name==null){ name = "no body"; } return "AXIS Hello,"+name; } }
编译AXISHelloService类后,将AXISHelloService.class文件拷贝到<Tomcat安装目录>\webapps\axis2\WEB-INF\pojo目录中。现在AXISHelloService已经发布成服务。
在浏览器地址栏中输入如下的URL,查看服务列表:
http://localhost:8080/axis2/services/listServices
在浏览器中输入两个URL测试sayHello与sayHelloToPerson方法:
http://localhost:8080/axis2/services/AXISHelloService/sayHello
http://localhost:8080/axis2/services/AXISHelloService/sayHelloToPerson?name=bill
<ns:sayHelloToPersonResponse xmlns:ns="http://ws.apache.org/axis2"> <return>AXIS Hello,bill</return> </ns:sayHelloToPersonResponse>
在编写、发布与测试AXIS2.0服务时,注意以下方面:
- POJO不能使用package关键字声明包。
-
AXIS2默认,热发布Web Service。即只要将Web Service的.class文件复制到pojo目录时,tomcat无需重新启动,即可自动发布Web Service。Web Service热发布的配置项在<Tomcat安装目录>\webapps\axis2\WEB-INF\conf\axis2.xml文件中,找到如下配置项:
<parameter name="hotdeployment">true</parameter>
-
AXIS2默认,是非热更新,即一旦发布Web Service,再更新Web Service,必须重启Tomcat。如果想设置AXIS2是热更新,则修改axis2.xml的以下配置项:
<parameter name="hotupdate">false</parameter>
- 在浏览器中测试WebService时,如果WebService方法有参数,需要使用URL的请求参数来指定该WebService方法。
- 发布Web Service的默认路径的pojo,可以手动添加其他目录,打开axis2.xml,在<axisconfig name="AxisJava2.0">节点之间,添加如下配置项
<deployer extension=".class" directory="deployPOJO" class="org.apache.axis2.deployment.POJODeployer"/>
(2)使用services.xml配置文件发布
AXIS2引擎发布Web Service,虽然POJO类直接拷贝至axis2\WEB-INF\pojo目录直接发布成Web Service,无需任何配置,但这些类无法处于任何包内。因此,AXIS2提供支持处于包中的POJO类发布成Web Service的方式,即services.xml方式。
相关推荐
Axis开发Web Service实例,介绍AXIS的三种方法
用axis2开发web service,过程比用axis1开发web service简单
基于AXIS2实现Web Service开发
WebService大讲堂之Axis2,Axis2教程,axis2教程例子,Web_Service实例应用
.Web Service简介 .如何开发一个Web Service .Axis2简介 .Axis2安装与部署 .Web Service开发步骤
AXIS2 是一个流行的 Web Service 引擎,它提供了一个强大的方式来构建 Web 服务。将 Spring 集成 AXIS2 可以实现基于 Spring 的 Web 服务配置,该配置方法可以提高开发效率和系统可维护性。 一、配置 Spring 项目 ...
Axis2创建web service快速入门
二、 Web Service服务器端的发布。 2.1 创建java类。 2.2 创建services.xml。 2.3 发布服务。 2.4 在浏览器上测试服务。 三、 Web Service 客户端的创建。 3.1 创建WSDL文件。 3.2 利用WSDL创建stub。 3.3 利用stub...
本资源是Web Service 的框架之一 Axis 集成Web网站示例代码
Axis2与Eclipse整合开发的Web Service的服务端
Chapter 1, Apache Web Services and Axis2 - Gives you an introduction to web services and the web service stack at Apache. Chapter 2, Looking inside Axis2 - Learn about Axis2 architecture and the ...
web service axis 1.6。配置说明,客户端,服务端代码
web service Axis2相关jar 里面包含了Axis2 java调用.net接口所需jar包
Web Service Axis2-1.6.2框架使用 压缩包里有:文档说明,axis2-1.6.2-bin.zip、axis2-1.6.2-war.zip、axis2-eclipse-codegen-plugin-1.6.2.zip、axis2-eclipse-service-plugin-1.6.2.zip。文档里用的所有jar压缩包...
4.Add the DynamicResponseHandler module reference to the axis2.xml configuration (located in WEB-INF/conf): <module ref="DynamicResponseHandler"/> 5.Add the JSON Message formatters to the axis2....
本文详细介绍了jdk tomcat axis 的安装配置,并发布了一个简单的web 服务
axis发布webservice教程axis发布webservice教程axis发布webservice教程axis发布webservice教程
在eclipse中用axis2开发Web Service,加快开发速度
web service架设完整流程,内附图解教学