将cxf与spring相关的架包拷到lib目录下,然后在classpath下新建一个cxfbeans.xml(进行cxf与spring的集成)文件和applicationContext.xml(进行ssh2的配置),

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"xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><!-- 配置数据源,导入c3p0-0.9.1.2.jar,mysql-connector-java-5.1.7-bin.jar --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"><property name="driverClass"><value>net.sourceforge.jtds.jdbc.Driver</value></property><property name="jdbcUrl"><value>jdbc:jtds:sqlserver://localhost:9433/web_exam</value></property><property name="user"><value>sa</value></property><property name="password"><value>123</value></property><!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 --><property name="initialPoolSize" value="1"/><!--连接池中保留的最小连接数。--><property name="minPoolSize" value="1"/><!--    连接池中保留的最大连接数。Default: 15 --><property name="maxPoolSize" value="300"/><!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --><property name="maxIdleTime" value="60"/><!--    当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --><property name="acquireIncrement" value="5"/><!--    每60秒检查所有连接池中的空闲连接。Default: 0 --><property name="idleConnectionTestPeriod" value="60"/><!--C3P0连接池设定,hibernate自带的连接池性能不行,而去使用第三方软件,如C3P0  连接池的最小连接数   <property name="hibernate.c3p0.min_size" value = "5"></property>  最大连接数   <property name="hibernate.c3p0.max_size" value = "30"></property>  连接超时时间  <property name="hibernate.c3p0.timeout" value = "1800"></property>  statemnets缓存大小   <property name="hibernate.c3p0.max_statements" value = "100"></property>  每隔多少秒检测连接是否可正常使用 ;最后在网上找到一个办法。为hibernate配置连接池,推荐用c3p0,然后配置c3p0的反空闲设置 idle_test_period,(只要小于MySQL的wait timeout即可,这句话后经证实不一定)。    <property name="hibernate.c3p0.idle_test_period" value = "121"></property>  当池中的连接耗尽的时候,一次性增加的连接数量,默认为3   <property name="hibernate.c3p0.acquire_increment" value = "1"></property>  <property name="hibernate.c3p0.validate" value = "true"></property>  --></bean><bean name="hibernateProperties"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><property name="properties"><props><prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop><!--<prop key="hibernate.hbm2ddl.auto">update</prop> --><prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop><!--<prop key="hibernate.show_sql">true</prop>--></props></property></bean><!--定义了Hibernate的SessionFactory --><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="hibernateProperties" ref="hibernateProperties" /><property name="mappingLocations"><list><value>classpath*:xidian/sl/entity/*.hbm.xml</value></list></property></bean><!-- 事务配置 --><bean id="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory" /></bean><bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"><!--  事务拦截器bean需要依赖注入一个事务管理器 --><property name="transactionManager" ref="transactionManager"/><property name="transactionAttributes"><!--  下面配置事务属性--><props><!--PROPAGATION_REQUIRE规则表示:在bean中所有以get开头的方法,当抛出异   常时,自动回滚,并只读,其他异常自动回滚-->  <!-- 事务处理,如果没有跟这里匹配的名,系统会默认是readOnly --><prop key="get*">PROPAGATION_REQUIRED,readOnly</prop><prop key="*">PROPAGATION_REQUIRED,-Exception</prop><prop key="*">ISOLATION_SERIALIZABLE</prop>  </props></property></bean><!-- 定义BeanNameAutoProxyCreator--><bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"><!--  指定对满足哪些bean name的bean自动生成业务代理 --><property name="beanNames"><!--  下面是所有需要自动创建事务代理的bean--><list><value>*Service</value><value>*DAO</value></list><!--  此处可增加其他需要自动创建事务代理的bean--></property><!--  下面定义BeanNameAutoProxyCreator所需的事务拦截器--><property name="interceptorNames"><list><!-- 此处可增加其他新的Interceptor --><value>transactionInterceptor</value> </list></property></bean><!-- 事务配置结束 --></beans>

cxfbeans.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:jaxws="http://cxf.apache.org/jaxws"xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"><import resource="classpath:META-INF/cxf/cxf.xml" />  <!-- 这些xml文件在cxf-2.5.0.jar的META-INF目录下--><!--<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />警告提示已经废弃了cxf-extension-soap.xml文件--><import resource="classpath:META-INF/cxf/cxf-servlet.xml" /><!-- 这里配置服务接口,后面描述id:指在spring配置的bean的ID.Implementor:指明具体的实现类.Address:指明这个web service的相对地址--><!-- 考生登录接口配置 --><!-- 这里service中DAo层的注入必须写在该配置文件中,因为客户端只能看到该配置文件 --><bean id="examineeLoginServiceImpl" class="xidian.sl.service.impl.webService.ExamineeLoginServiceImpl" ><property name="examineeLoginDAO" ref="examineeLoginDAO"></property></bean><jaxws:endpoint id="examineeLoginService" implementor="#examineeLoginServiceImpl"address="/examineeLogin" /><!-- 考试开始接口配置 --><bean id="examStartServiceImpl" class="xidian.sl.service.impl.webService.ExamStartServiceImpl" ><property name="examStartDAO" ref="examStartDAO"></property></bean><jaxws:endpoint id="examStartService" implementor="#examStartServiceImpl"address="/examStart" /><!-- 接受答案处理 --><bean id="answerManageServiceImpl" class="xidian.sl.service.impl.webService.AnswerManageServiceImpl" ><property name="answerManageDAO" ref="answerManageDAO"></property></bean><jaxws:endpoint id="answerManageService" implementor="#answerManageServiceImpl"address="/answerManage" /><!-- 开启tomcat服务器 ,访问http://localhost:8080/WebExam/services/zipTest?wsdl http://localhost:8080/WebExam是本项目的访问地址
services是由于web.xml配置所得,zipTest是由于Spring配置文件中的address属性所得--></beans>

要使得客户端能够正常的调用,我们还必须在web.xml下进行访问地址的配置,即配置Servlet(org.apache.cxf.transport.servlet.CXFServlet)的访问

web.xml:

<servlet><servlet-name>CXFServlet</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>CXFServlet</servlet-name><url-pattern>/services/*</url-pattern></servlet-mapping>

转载于:https://www.cnblogs.com/shenliang123/archive/2012/04/16/2451570.html

将webService(CXF)与spring集成相关推荐

  1. 使用CXF与Spring集成实现RESTFul WebService

    以下引用与网络中!!! 一种软件架构风格,设计风格而不是标准,只是提供了一组设计原则和约束条件.它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制. ...

  2. Spring集成CXF发布WebService并在客户端调用

    Spring集成CXF发布WebService 1.导入jar包 因为官方下载的包里面有其他版本的sprring包,全导入会产生版本冲突,所以去掉spring的部分,然后在项目根目录下新建了一个CXF ...

  3. wsld2java_脱离spring集成cxf(基于nutz框架)

    什么是webService cxf 简单的说就是实现webService的一个比较流行的框架 http://blog.sina.com.cn/s/blog_6182547f01017pak.html ...

  4. 使用Apache cxf 和Spring在Tomcat下发布Webservice指南

    转载 http://blog.csdn.net/zhangzhaokun/article/details/4750021 最近学习了如何使用apache cxf和Spring发布webservice, ...

  5. CXF整合Spring开发WebService

    刚开始学webservice时就听说了cxf,一直没有尝试过,这两天试了一下,还不错,总结如下: 要使用cxf当然是要先去apache下载cxf,下载完成之后,先要配置环境变量,有以下三步: 1.打开 ...

  6. CXF:是一个开源Service框架支持多种协议:SOAP、XML/HTTP、RestfulHTTP和CORBA,同时可以和Spring集成。

    CXF:是一个开源Service框架 支持多种协议:SOAP.XML/HTTP.RestfulHTTP和CORBA,同时可以和Spring集成.

  7. WebService CXF系列: SpringBoot同一个项目中集成JaxWS和JaxRS

    WebService CXF系列: SpringBoot同一个项目中集成JaxWS和JaxRS 介绍 项目介绍 项目架构 项目介绍 项目集成的原则 SpringBoot集成JaxWS 1. JaxWs ...

  8. Activiti学习——Activiti与Spring集成

    与Spring集成 基础准备 目录结构 相关jar包 Activiti的相关jar包  Activiti依赖的相关jar包  Spring的相关jar包  Spring依赖的相关jar包  本示例相关 ...

  9. cxf和spring整合

    spring 3.0 cxf2.7.2整合 1,拷贝spring的 jar 2,拷贝cxf的jar包     jetty不需要了     asm     common-logging     neet ...

  10. apache camel_轻量级的开源集成:Apache Camel还是Spring集成?

    apache camel 首先,为全面披露信息,在过去的1.5年中, 我一直担任 FuseSource(现为Red Hat) 的顾问,为零售,运输,银行/金融等不同行业的大型和小型公司提供SOA和集成 ...

最新文章

  1. js数组的排序 sort详解
  2. AI 系统的发展趋势与挑战 | 智源大会-AI系统专题论坛
  3. R语言:ggplot2
  4. extern C的用法解析
  5. 年少成名的我并没有放弃自己,谁敢说她\他文章比我写的好?!,不服来战!...
  6. 机器学习笔记十之聚类
  7. 推荐一款华为最新的自动化代码检查工具
  8. 神经网络与深度学习(邱锡鹏版本)学习笔记11.23
  9. 【已解决】华为手机USB调试和监控ADB安装应用的选项变成了灰色如何解决 | 华为荣耀9手机USB调试和监控ADB安装应用选项变成了灰色怎么办
  10. Power BI——关系函数(RELATED和RELATEDTABLE)
  11. ffmpeg的那点小事儿--编译ffmpeg同时支持libx264(视频编码)和libfdk(音频编码)
  12. 通用技术金工工艺高考必考必看的知识点含攻丝与套丝讲解
  13. html不间断滚动图片,不间断循环滚动图片,jsp网页代码
  14. SDUT 3386 小雷的冰茶几
  15. 浙江省政协十二届二次会议在杭州开幕
  16. T-SQL 学习之路之数据库完整性之域完整性
  17. Android4.0新的SDK新特性 (转)
  18. mysql的硬件要求_MySQL的最低硬件要求?
  19. Linux中su的使用说明
  20. 媳妇,我竟然要补这么多税……

热门文章

  1. 四大障碍将阻止或减缓广电发展宽带业务
  2. 一个小小的签到功能,到底用MySQL还是Redis?
  3. 不要为了“分库分表”而“分库分表”!
  4. popen 如何获取指令执行情况_php通过popen获取的一个命令的返回值如何分析出来...
  5. 史上最强Dubbo面试26题和答案:核心组件+服务治理+架构设计等
  6. Ubuntu 网速显示,ssh配置
  7. jboss7学习2-jboss7入门(端口和访问的ip问题)
  8. 淘宝大牛们——晒一晒淘宝网技术内幕
  9. 系统性能优化- Session丢失
  10. 使用HTML5构建iOS原生APP(2)