有一个最简单的方法就是把axis2.war中的内容作为web app的基础, 来进行开发. 不过为了更清楚的了解如何在一个已有的web app中嵌入axis2, 那就只能手动了.
1. 把以下内容copy到已有的web app中
axis2.war/axis2-web
axis2.war/WEB-INF/*
2. 在web.xml中配置axis2 servlet
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
3. 创建自己的Service Bean
package example;
public class HelloWorldService {
public HelloWorldService() {
}
public String hello() {
return "Hello axis2 service!";
}
}
4. 配置Web Service.
由于axis2嵌入了web app, 所以web service就不用打包成aar,而是直接在/WEB-INF目录下创建相应的文件夹和services.xml
/WEB-INF
/services
/HelloWorld
/META-INF
services.xml
5. 配置services.xml的内容
<serviceGroup>
<service name="HelloWorldService">
<description>Hello World Service</description>
<parameter name="ServiceClass" locked="false">example.HelloWorldService</parameter>
<operation name="hello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
6. 测试
如果一切OK的话, 在浏览器中输入http://localhost:8080/example/services/HelloWorldService?wsdl就应该可以看到输出的wsdl xml.
Done!
其实在项目中还集成了Spring, 不过这个应该相对简单.
1. 需要把Spring的jar放到/WEB-INF/lib中
2. services.xml中service的ServiceObjectSupplier用org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
HelloWorldSpringService.java
package example;
public class HelloWorldSpringService {
public String hello() {
return "Hello spring axis2 service!";
}
}
In services.xml:
<serviceGroup>
<service name="HelloWorldService">
<description>Hello World Service</description>
<parameter name="ServiceClass" locked="false">example.HelloWorldService</parameter>
<operation name="hello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
<service name="HelloWorldSpringService">
<description>Hello World Spring Service</description>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">HelloWorldSpringService</parameter>
<operation name="hello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
In applicationContext.xml
<bean id="HelloWorldSpringService" class="example.HelloWorldSpringService"/>
参考:
How to Embed an Axis2 based Web Service in your Webapp? | WSO2 Oxygen Tank
wso2.org/library/90
Axis2 Integration with the Spring Framework
http://ws.apache.org/axis2/1_3/spring.html
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bruni/archive/2008/03/17/2193060.aspx
分享到:
相关推荐
Axis2 Web Service 开发教程, axis2_WebService_开发指南
简单地描述下怎么使用 eclipse 生成 Axis2 Web Service 客户端。
通向架构师的道路(第十三天)Axis2 Web Service安全初步
通向架构师的道路(第十天)之Axis2 Web Service(一).
通向架构师的道路(第十二天)之Axis2 Web Service(三)
通向架构师的道路(第十一天)之Axis2 Web Service(二)
web service架设完整流程,内附图解教学
通向架构师的道路(第十四天)Axis2 Web Service安全之rampart
Axis开发Web Service实例,介绍AXIS的三种方法
Extensive and detailed coverage of the enterprise ... Written by Deepal Jayasinghe, a key architect and developer of the Apache Axis2 Web Service project; and Afkham Azeez, an elected ASF and PMC member.
用axis2开发web service,过程比用axis1开发web service简单
基于AXIS2实现Web Service开发
Axis2创建web service快速入门
web service在web接口系统中是jms中很不错的一个选择。而axis又是开发web service的不二人选。本文通过理论结合实例的方式讲解如何通过axis来开发web service。所有实例代码均可copy运行成功。
.Web Service简介 .如何开发一个Web Service .Axis2简介 .Axis2安装与部署 .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 ...
通过该实验将掌握配置MyEclipse7.0的axis Web Service的开发环境,通过Top-Down方式创建、发布基于axis Web Service的基本步骤,进一步加深学生对XML、WSDL、SOAP等Web Service概念的理解。
使用AXIS开发Web Service 客户端调用的三种方式都有完整例子及步骤
使用Axis开发Web Service程序 在文档中进行了最简单的说明和举例 对于简单框架搭建进行了代码举例