`
darrendu
  • 浏览: 195726 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

07_CXF与Web项目集成---with Spring

    博客分类:
  • CXF
阅读更多

1.CXF本身就使用了Spring的东西,它和Spring集成可谓是无缝集成

   主要让发布服务的任务交spring去发布

 

2.配置web.xml

  配置spring

 

<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/beans.xml</param-value>
	</context-param>

	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>

 

 

  配置我们的cxf

 

<!-- 配置CXF Servlet -->
	<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>/*</url-pattern>
	</servlet-mapping>

 

3.beans.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- START SNIPPET: beans -->
<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.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

 
    <!--会向cxf jar包去找  -->
	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	<!-- 
	<jaxws:endpoint 
	  id="helloWorld" 
	  implementor="com.cxf.server.HelloWorldImpl" 
	  address="/HelloWorld" />
	-->
	  
	  <!-- 另一种发布方式 -->
	  <bean id="hello" class="com.cxf.server.HelloWorldImpl"/>
	  <jaxws:endpoint id="helloWorld" 
	  				  implementor="#hello"
	  				  address="/HelloWorld">
	  				  
	  </jaxws:endpoint>
	  	
	  <bean id="us" class="com.cxf.users.UserServiceImpl"></bean>
	  
	  <jaxws:endpoint id="userService"
	  				  implementor="#us"
	  				  address="/userAction"
	  				  >
	  		<jaxws:inInterceptors>
	  			<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
	  		</jaxws:inInterceptors>
	  				
	  		<jaxws:outInterceptors>
	  			<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
	  		</jaxws:outInterceptors>
	  </jaxws:endpoint>
	  
</beans>
<!-- END SNIPPET: beans -->

 

 <jaxws:endpoint  通过他们进行服务发布,通过其指定的address访问你的wsdl

 

<jaxws:inInterceptors>
	  			<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
	  		</jaxws:inInterceptors>

 可以加入相关interceptor

 

 

分享到:
评论
1 楼 aishu 2012-02-25  

相关推荐

    apache-cxf-3.1.1跟3.1.6所有jar包

    6. **Spring集成**:CXF与Spring框架深度集成,使得服务的配置和管理变得更加方便,同时也易于与其他Spring生态系统的组件配合使用。 7. **安全性**:CXF提供了多种安全机制,如基本认证、Digest认证、OAuth、SSL/...

    Building-Web-Services-with-Java.zip_building_web services

    8. **持续集成与部署**:项目中可能包含如何将Web服务集成到CI/CD(持续集成/持续部署)流程中,如使用Jenkins或GitLab CI/CD,以及如何在服务器上部署服务。 通过学习和实践这个压缩包中的内容,开发者可以深入...

    apache-cxf-2.1.4

    7. **Spring框架集成**:CXF可以很好地与Spring框架结合,使得服务的配置和管理变得更加容易。 8. **安全性**:CXF提供了各种安全机制,包括基本认证、 Digest认证、SSL/TLS、WS-Security等,确保服务的安全性。 9...

    JAX-WS-Web-Service-with-Apache-CXF-and-Spring-frameworks

    **JAX-WS与Apache CXF和Spring框架的整合** 在Java世界中,JAX-WS(Java API for XML Web Services)是用于构建和消费Web服务的标准API,它基于SOAP协议,提供了一种规范化的、面向服务的架构(SOA)实现方式。...

    apache-cxf-2.7.6

    6. **Integration with Spring Framework**:CXF与Spring框架深度集成,可以方便地在Spring应用上下文中配置和管理Web服务。 7. **Extensive Documentation and Community**:Apache CXF拥有详尽的文档和活跃的社区...

    web-services-with-java.zip_java web

    在Java中,Spring Security可以集成到Web服务项目中,提供身份验证和授权机制。 8. **测试Web服务**:JUnit和Mockito等工具用于单元测试,而Apache HttpClient或RestAssured可以帮助进行集成测试和端到端测试,确保...

    apache-cxf-3.0.15.zip

    - **集成Spring框架**:CXF与Spring框架有很好的集成,可以利用Spring的依赖注入和配置管理能力,使得Web服务的部署和管理更加灵活。 - **国际化和安全性**:CXF支持多种国际化和安全策略,包括SSL/TLS加密、WS-...

    apache-cxf-3.1.5.zip

    4. **集成能力**:CXF可以轻松地与Spring框架集成,提供声明式服务配置。此外,它还支持OSGi(Open Service Gateway Initiative)环境,适用于模块化开发。 5. **数据绑定**:CXF支持JAXB(Java Architecture for ...

    实战Web Service —— 使用Apache CXF开发Web服务的教程

    【标题】:“实战Web Service —— 使用Apache CXF开发Web服务的教程” 【内容详解】: ...通过本教程,你将能够掌握使用Apache CXF开发Web服务的基本流程和技巧,为后续的Web服务项目打下坚实基础。

    apache-cxf-2.7.18.rar

    8. **Spring集成**:Apache CXF可以与Spring框架紧密集成,利用Spring的依赖注入和配置管理,使得Web服务的开发更加灵活和模块化。 9. **测试和调试工具**:CXF提供了丰富的工具,如CXF TestSuite、CXF wsdl2java...

    apache-cxf-3.1.9

    7. **集成性**:CXF可以很容易地与Spring框架集成,使得配置和服务管理变得更加简单。此外,它还支持OSGi环境。 8. **测试和调试**:CXF提供了测试工具,如模拟服务器和客户端,方便进行服务的测试和调试。 在...

    apache-cxf-2.7.12

    Apache CXF可以很好地与Spring框架集成,允许开发者利用Spring的依赖注入和配置管理来构建Web服务。通过Spring,你可以更方便地管理CXF服务和客户端的生命周期。 在"apache-cxf-2.7.12"这个版本中,包含了所有必要...

    apache-cxf-3.4.5.zip

    6. **插件系统**:CXF拥有强大的插件体系,允许扩展和定制,如Spring框架的集成、安全认证、拦截器等。 **3.4.5版本可能包含的改进:** 1. **性能提升**:新版本通常会针对之前版本的性能瓶颈进行优化,提高服务...

    spring2.5+ibatis3+web service cxf 例子MyEclipse工程

    标题 "spring2.5+ibatis3+web service cxf 例子MyEclipse工程" 提供了一个关于如何在MyEclipse环境中集成Spring 2.5、iBatis 3和Web Service CXF的实例。这个工程是开发人员学习和实践这些技术的一个起点,通过它,...

    cxf完整开发工具包

    8. **Integration with Spring**:CXF可以很好地与Spring框架集成,利用Spring的依赖注入和配置管理,简化服务的创建和部署。 9. **Testing Support**:CXF提供了测试工具和框架,如模拟服务器(Mock Server),...

    apache-cxf-2.2.12.rar

    9. **与Spring框架的集成**:CXF可以轻松地与Spring框架结合,利用Spring的依赖注入和管理能力。 10. **丰富的社区支持**:作为Apache软件基金会的项目,Apache CXF拥有活跃的开发者社区,提供文档、教程、论坛支持...

    cxf-3.0.0 src

    6. **集成框架**:CXF可以轻松地与Spring框架集成,使得配置和服务管理更加便利。 7. **安全性**:CXF提供了丰富的安全特性,包括WS-Security、OAuth等,确保Web服务的安全通信。 8. **国际化和本地化**:CXF支持...

    CXF入门.rar

    通过以上分析,我们可以看出,这个压缩包提供了从基础到进阶的CXF学习资料,包括CXF与Spring的集成、CXF在实际项目中的应用,以及与Struts2的整合示例,对于初学者或者希望深入理解CXF的开发者来说,是非常宝贵的...

    PacktPub.Apache.CXF.Web.Service.Development.Dec.2009.rar

    8. **集成Spring框架**:学习如何将CXF服务与Spring容器结合,利用Spring的依赖注入和事务管理能力。 9. **RESTful服务开发**:学习如何使用JAX-RS创建RESTful服务,以及如何处理HTTP方法和资源。 10. **高级话题*...

    webService 生成插件apache-cxf(2.7.7)

    9. **Integration with Build Tools**:Apache CXF可以很好地与Maven、Gradle等构建工具集成,方便在项目构建过程中生成和发布Web服务。 10. **Documentation Generation**:CXF能够自动生成服务的WSDL和XSD,以及...

Global site tag (gtag.js) - Google Analytics