CXF2.1.1+Spring2.5+Hibernate3.2开发Web Service的配置方法

 

 CXF(http://cxf.apache.org/)和Spring(http://cxf.apache.org/)无缝集成的Web Service开发框架。CXF目前是APACHE的孵化项目,也是目前JAVA领域十分热门和有前途的Web Service开发框架。最近在一个研发项目中需要提供Web Service服务,调用方是.NET开发的系统。通过分析选择,最终决定采用CXF来做。

      CXF、SPRING和HIBERNATE版本更新都比较快,把几个东西搁一块就会出现些不兼容的问题。我将最新的CXF 2.1Spring 2.5 Hibernate 3.2放到一起,系统启动时报“Unsatisfied dependency expressed through constructor argument with index 2 of type [org.apache.cxf.jaxws.JaxWsServerFactoryBean]: 的错误。在cxfmail-list CXF-ZHhttp://groups.google.com/group/cxf-zh 没找到合适解答。经过一番分析测试,现将解决上述问题的方案提供给大家:

       1CXF 下载最新的 CXF 2.1.1(http://people.apache.org/repo/m2-snapshot-repository/org/apache/cxf/apache-cxf/2.1.1-SNAPSHOT/

)

       2、在lib下应该使用如下版本的类库文件

           cxf-2.1.1-SNAPSHOT.jar          

           asm-2.2.3.jar(在Spring 2.5里,替换掉hibernate3.2里自带的)

           hibernate3.2.6.jar

           cglib-nodep-2.1_3.jar(去掉老的cglib

           spring-core.jar

           spring-web.jar

           spring-webmvc.jar

           hibernate-annotations.jar

           hibernate-commons-annotations.jar

           cxf 2.1.1相关的类库

           commons-logging-1.1.jar

           geronimo-activation_1.1_spec-1.0.2.jar

           geronimo-annotation_1.0_spec-1.1.1jar

           geronimo-javamail_1.4_spec-1.3.jar

           geronimo-servlet_2.5_spec-1.2.jar (or Sun's Servlet jar)

           geronimo-stax-api_1.0_spec-1.0.1.jar

           geronimo-ws-metadata_2.0_spec-1.1.2.jar (JSR 181)

           jaxb-api-2.1.jar

           jaxb-impl-2.1.6.jar

           jaxws-api-2.1-1.jar

           neethi-2.0.4.jar

           saaj-api-1.3.jar

           saaj-impl-1.3.jar

           wsdl4j-1.6.1.jar

           wstx-asl-3.2.4.jar

           XmlSchema-1.4.2.jar

           xml-resolver-1.2.jar

     3、编写spring的配置文件时应该注意采用如下结构形式(helloWorld.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:cxf="http://cxf.apache.org/core"

xmlns:jaxws="http://cxf.apache.org/jaxws"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-2.5.xsd

http://cxf.apache.org/core

http://cxf.apache.org/schemas/core.xsd

http://cxf.apache.org/jaxws

http://cxf.apache.org/schemas/jaxws.xsd">  

 

<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" />

 

<bean id="helloWorldImpl" class="lee.ws.HelloWorldImpl" />

<jaxws:endpoint id="helloWorld"  implementor="#helloWorldImpl" implementorClass="lee.ws.HelloWorldImpl"   address="/HelloWorld">  

<jaxws:serviceFactory>  

<bean  

class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">  

<property name="wrapped" value="true" />  

</bean>  

</jaxws:serviceFactory>  

        </jaxws:endpoint> 

 

</beans>

 

 OK,希望这篇文章对大家有所帮助.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值