你好,游客 登录 注册 搜索
背景:
阅读新闻

Spring3.0+CXF WebService开发

[日期:2012-12-20] 来源:Linux社区  作者:sundenskyqq [字体:大 中 小]

配置文件1:(web.xml配置文件 加入cxf相关配置文件)

<!-- CXF Web Services 配置信息 -->
 <servlet>
  <display-name>CXF Servlet</display-name>
  <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><!--注意这里的配置/services/ 这里是生成wsdl路径的一部分,wsdl的路径:http://ip:8080/项目路径/services/spring cxf配置文件中的address?wsdl-->
 </servlet-mapping>

配置文件2:(spring cxf 配置文件)

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

 <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.cslc.crius.common.ws.cxf.server.HelloWorldImpl"
  address="/HelloWorld" />
 
 <jaxws:endpoint
  id="workUnitInfo"
  implementor="#workUnitInfoImpl"
  address="/WorkUnitInfo"
 />
 <bean id="workUnitInfoImpl" class="com.cslc.crius.common.ws.cxf.server.WorkUnitInfoImpl">

&nbsp;<!--如果webservice中有需要加载其他类,采用注解的方式不行,需要在配置文件中显示声明--> &nbsp;
  <property name="workUnitService" ref="workUnitServiceImpl"></property>
 </bean>
 
</beans>
<!-- END SNIPPET: beans -->

以上几步完成以后既可以进行相关的测试了,发布到tomcat服务器中,启动服务器。

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款