spring整合axis2(最小配置化)的示例
参考文档:
http://blog.csdn.net/xinhaoluan/article/details/3605234
环境配置:
实现步骤:
1.eclipse新建Dynamic Web Project,本例工程名为:ws-sample
2.将spring-framework和axis2的lib加入工程中
3.编写测试服务:
IHello.java(interface)
package com.lichmama.ws.demo.intf;
public interface IHello {
public String sayHello(String name);
}
HelloImpl.java(class)
package com.lichmama.ws.demo.service;
import org.springframework.stereotype.Service;
import com.lichmama.ws.demo.intf.IHello;
@Service("helloService")
public class HelloImpl implements IHello {
@Override
public String sayHello(String name) {
if((name == null) || (name == "")) {
name = "anonymous";
}
return "hello, " + name;
}
}
3.新建spring配置文件/WEB-INF/applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config />
<context:component-scan base-package="com.lichmama.ws.demo" /> <bean id="applicationContext"
class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
</beans>
4.新建/WEB-INF/services/axis2/META-INF/services.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<serviceGroup>
<service name="HelloService" scope="application">
<description>simple spring example</description>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
</parameter>
<parameter name="SpringBeanName">helloService</parameter>
<messageReceivers>
<messageReceiver mep= "http://www.w3.org/2004/08/wsdl/in-only"
class = "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep= "http://www.w3.org/2004/08/wsdl/in-out"
class = "org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
</service>
</serviceGroup>
5.配置/WEB-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0"> <display-name>ws-sample</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param> <servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list> </web-app>
6.完成以上工作后工程目录结构如下:

7.发布工程,启动tomcat
8.访问http://localhost:8080/ws-sample/services/HelloService?wsdl,查看服务是否发布成功。
如果发布成功的话,访问http://localhost:8080/ws-sample/services/HelloService/sayHello?name=lichmama结果应该如下:

9.*简易的做法是下载axis2-war.zip(http://archive.apache.org/dist/axis/axis2/java/core/1.6.2/axis2-1.6.2-war.zip),复制WEB-INF下的文件到工程对应目录。
然后再根据实际情况修改各配置文件(application.xml, services.xml, web.xml)。
10.*上述示例工程下载地址:http://pan.baidu.com/s/1hrBsZ4o
spring整合axis2(最小配置化)的示例的更多相关文章
- 初识quartz 并分析 项目中spring整合quartz的配置【原创+转载】
初识quartz 并分析 项目中spring整合quartz的配置[原创+转载]2018年01月29日 12:08:07 守望dfdfdf 阅读数:114 标签: quartz 更多个人分类: 工具 ...
- spring整合mybatis(hibernate)配置
一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...
- spring 整合 hibernate xml配置
spring 整合 hibernate: hibernate :对数据库交互 spring: ioc aop 整合点: 1.sessionFactory对象不再由hibernate生成,交由spr ...
- Spring第十一篇——–Spring整合Hibernate之配置数据源
DataSource(数据源)提供了一个标准化的取得数据库连接的方式,通过getConnection()方法即可取得数据库的连接,Spring也提供了数据库连接池(DataBase connectio ...
- Spring整合Struts2的配置与测试
整合目的 让Spring的IOC容器管理Struts2的Action 整合步骤 1.新建一个Web项目 2.加入Spring的jar包和添加Spring的配置文件 3.在Web.xml中配置Conte ...
- spring 整合 struts2 xml配置
整合之前要搞清楚struts2是什么; struts2:表现层框架 增删改查 作用域 页面跳转 异常处理 ajax 上传下载 excel 调用service spring :IOC/ ...
- mybatis和spring整合的关键配置
spring配置文件 applicationContext.xml: <beans xmlns="http://www.springframework.org/schema/beans ...
- 阶段3 3.SpringMVC·_07.SSM整合案例_09.ssm整合之Spring整合MyBatis框架配置事务
spring加入声明式的事物 配置事物 配置事物管理器 需要一个dataSource,引入上面的dataSource 配置事务通知 引入上面的transactionManager事物管理器 find开 ...
- Spring 整合 Redis (零配置) 的简单使用
pom.xml <!--jedis--> <dependency> <groupId>redis.clients</groupId> <artif ...
随机推荐
- CoreOS, Kubernetes, etcd
CoreOS CoreOS Container Linux is the leading container operating system, designed to be managed and ...
- 【面向对象设计原则】之接口隔离原则(ISP)
接口隔离原则(Interface Segregation Principle, ISP):使用多个专门的接口,而不使用单一的总接口,即客户端不应该依赖那些它不需要的接口. 从接口隔离原则的定义可以看 ...
- Centos 环境一键部署脚本(shell脚本)
谨以此文纪念吊炸天的Centos环境一键部署方案的新鲜出炉 辛苦大半年,产品准备上线了,BOSS亲自体验安装部署,看着超过200+页的安装文档直接崩溃了(需要部署23个基础服务),经历了超过3个小时的 ...
- Html5模拟通讯录人员排序(sen.js)
// JavaScript Document var PY_Json_Str = ""; var PY_Str_1 = ""; var PY_Str_2 = & ...
- BOM(1)
BOM 浏览器对象模型(Browser Object Model),使浏览器对象模型 (BOM) 使 JavaScript 有能力与浏览器"对话". 浏览器对象模型(Browser ...
- docker疑难解答 -- 设置远程服务监听
环境: ubuntu 16.04 tls docker version 17.05.0-ce ========================= 今天想要搭建一个多主机的集成docker环境,但是我最 ...
- HttpWebRequest操作已超时
最近我们使用.NET3.5HttpWebRequest会报操作已超时但使用.NET4.0版本及以上却可以正常访问. 一段简单的代码如下: string returnData = "" ...
- vue2.0 配置 选项 属性 方法 事件 ——速查
全局配置 silent 设置日志与警告 optionMergeStrategies 合并策略 devtools 配置是否允许vue-devtools errorHandler 错误 ...
- easyUI的简单了解
首先简单的介绍一下jQuery EasyUI,它是一组基于jQuery的UI插件集合体,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面.开发者不需要编写 ...
- Why you should QC your reads AND your assembly?
鲤鱼基因组:http://www.ntv.cn/a/20140923/52953.shtml 关于鲤鱼基因组的测定,数据质量控制遭到质疑. Why you should QC your reads ...