手机版
你好,游客 登录 注册
背景:
阅读新闻

CXF使用Tomcat发布WebService的简单例子

[日期:2011-12-13] 来源:Linux社区  作者:joy_joe [字体:大 中 小]

Client and below files are same with last article.

HelloWorld.Java

HelloWorldImpl.java

Server:

Add two files as belows to folder WEB-INF

beans.xml

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.        xmlns:jaxws="http://cxf.apache.org/jaxws"  
  5.        xsi:schemaLocation="  
  6.         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
  7.         http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">  
  8.   
  9.     <import resource="classpath:META-INF/cxf/cxf.xml" />  
  10.     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
  11.     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
  12.     <jaxws:endpoint id="webServiceHelloWorld"  
  13.         address="/HelloWorld"  
  14.         implementor="joe.test.cxf.HelloWorldImpl"/>  
  15. </beans>  

web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <web-app version="2.5"   
  4.      xmlns="http://java.sun.com/xml/ns/javaee"   
  5.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  6.      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  7.      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
  8.      <context-param>  
  9.         <param-name>contextConfigLocation</param-name>  
  10.         <param-value>WEB-INF/beans.xml</param-value>  
  11.     </context-param>  
  12.     <listener>  
  13.         <listener-class>  
  14.             org.springframework.web.context.ContextLoaderListener  
  15.         </listener-class>  
  16.     </listener>  
  17.      <servlet>  
  18.          <servlet-name>CXFServlet</servlet-name>  
  19.          <servlet-class>  
  20.               org.apache.cxf.transport.servlet.CXFServlet  
  21.          </servlet-class>  
  22.      </servlet>  
  23.      <servlet-mapping>  
  24.          <servlet-name>CXFServlet</servlet-name>  
  25.          <url-pattern>/services/*</url-pattern>  
  26.      </servlet-mapping>  
  27. </web-app>  
linux
相关资讯       Tomcat  CXF 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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