服务接口及实现类请參考WebService框架CXF实战(一)

创建Maven Web项目,在pom.xml中加入CXF和Spring Web的引用,因为CXFServlet须要Spring Web的支持。

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>com.rvho</groupId>
  5. <artifactId>cxfserver</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. <packaging>war</packaging>
  8. <properties>
  9. <!-- CXF版本号 -->
  10. <cxf.version>3.1.1</cxf.version>
  11. </properties>
  12. <dependencies>
  13. <!-- CXF -->
  14. <dependency>
  15. <groupId>org.apache.cxf</groupId>
  16. <artifactId>cxf-rt-frontend-jaxws</artifactId>
  17. <version>${cxf.version}</version>
  18. </dependency>
  19. <dependency>
  20. <groupId>org.apache.cxf</groupId>
  21. <artifactId>cxf-rt-transports-http</artifactId>
  22. <version>${cxf.version}</version>
  23. </dependency>
  24. <!-- End CXF -->
  25. <!-- 因为CXFServlet须要Spring Web的支持 -->
  26. <dependency>
  27. <groupId>org.springframework</groupId>
  28. <artifactId>spring-web</artifactId>
  29. <version>4.1.7.RELEASE</version>
  30. </dependency>
  31. </dependencies>
  32. </project>

在WEB-INF下创建cxf-servlet.xml配置文件。

  1. <?
  2. xml version="1.0" encoding="UTF-8"?
  3. >
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:jaxws="http://cxf.apache.org/jaxws"
  7. xmlns:soap="http://cxf.apache.org/bindings/soap"
  8. xsi:schemaLocation="
  9. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
  11. http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
  12. <jaxws:server id="helloWSServer" serviceClass="com.rvho.cxfserver.ws.HelloWS" address="/hello">
  13. <jaxws:serviceBean>
  14. <bean class="com.rvho.cxfserver.ws.impl.HelloWSImpl" />
  15. </jaxws:serviceBean>
  16. </jaxws:server>
  17. </beans>

在WEB-INF/web.xml中加入CXFServlet配置,CXFServlet匹配/services路径下的全部请求。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns="http://java.sun.com/xml/ns/javaee"
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  5. id="WebApp_ID" version="3.0">
  6. <display-name>cxfserver</display-name>
  7. <!-- CXF Servlet -->
  8. <servlet>
  9. <servlet-name>cxfservlet</servlet-name>
  10. <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
  11. </servlet>
  12. <servlet-mapping>
  13. <servlet-name>cxfservlet</servlet-name>
  14. <!-- 匹配/services下的全部请求 -->
  15. <url-pattern>/services/*</url-pattern>
  16. </servlet-mapping>
  17. <!-- End CXF Servlet -->
  18. <welcome-file-list>
  19. <welcome-file>index.html</welcome-file>
  20. <welcome-file>index.jsp</welcome-file>
  21. </welcome-file-list>
  22. </web-app>



启动Tomcat后。在浏览器中输入http://<站点路径>/cxfserver/services就可以看到例如以下效果,因为这里配置CXFServlet的路径是/services,假设配置其它路径,服务的请求路径也不一样。只是大体上是http://<站点路径>/cxfserver/

CXF实战之在Tomcat中公布Web Service(二)的更多相关文章

  1. CXF之三 Tomcat中发布Web Service

    服务接口及实现类请参考CXF之一 创建Maven Web项目,在pom.xml中添加CXF和spring Web的引用,由于CXFServlet需要Spring Web的支持. <project ...

  2. 用JAX-WS在Tomcat中公布WebService

    JDK中已经内置了Webservice公布,只是要用Tomcat等Webserver公布WebService,还须要用第三方Webservice框架. Axis2和CXF是眼下最流行的Webservi ...

  3. 在Tomcat中部署Web项目的操作方法,maven项目在Tomcat里登录首页报404

     maven项目在Tomcat里登录首页报404, 解决:编辑conf/server.xml进行配置<Host>里的<Context>标签里的path. <Context ...

  4. 在Tomcat中部署web项目的三种方式

    搬瓦工搭建SS教程 SSR免费节点:http://www.xiaokeli.me 在这里介绍在Tomcat中部署web项目的三种方式: 1.部署解包的webapp目录 2.打包的war文件 3.Man ...

  5. Tomcat中部署web应用的三种方式

    Tomcat中部署web应用的三种方式(静态部署)       第一种,针对war或解压后的war,最为常用的是直接操作webapp目录,将完整的war包或者web应用直接放到webapp目录下.使用 ...

  6. Tomcat 中部署 web 应用 ---- Dubbo 服务消费者 Web 应用 war 包的部署

    使用Maven构建Dubbo服务的可执行jar包 Dubbo服务的运行方式: 1.使用Servlet容器运行(Tomcat.Jetty等)----不可取 缺点:增加复杂性(端口.管理) 浪费资源(内存 ...

  7. 谈谈EJB是怎样公布Web Service的

    定义 我们常常会听到.xx项目中用到了Web Service.那么.什么是Web Service呢? 首先让我们来了解一下Web Service.Web Service技术.就是能使得执行在不同机器上 ...

  8. 你会在C#的类库中添加web service引用吗?

    本文并不是什么高深的文章,只是VS2008应用中的一小部分,但小部分你不一定会,要不你试试: 本人对于分布式开发应用的并不多,这次正好有一个项目要应用web service,我的开发环境是vs2008 ...

  9. 微软BI 之SSIS 系列 - 在 SSIS 中使用 Web Service 以及 XML 解析

    开篇介绍 Web Service 的用途非常广几乎无处不在,像各大门户网站上的天气预报使用到的第三方 Web Service API,像手机客户端和服务器端的交互等都可以通过事先设计好的 Web Se ...

随机推荐

  1. 紫书 习题 11-17 UVa 1670 (图论构造)

    一开始要符合题目条件, 那么肯定没有任何一个点是孤立的, 也就是说没有点的度数是1 所以我就想让度数是1的叶子节点相互连起来.然后WA 然后看这哥们的博客 https://blog.csdn.net/ ...

  2. 题解 P2532 【[AHOI2012]树屋阶梯】

    本题运用卡特兰数求解. 卡特兰数有两种表达方式: 1)\(h_i=\sum^{k=0}_{i-1}h_kh_{i-k-1}\) 2)\(h_i=\frac{1}{n+1}C^{n}_{2n}\) 运用 ...

  3. CAS-ERR Cannot create a session after the response has been committed

    现象: 当cas 登录人数较少时候没有错误,但是用户过多时候出现下列err May-2016 18:09:11.932 SEVERE [http-nio-8080-exec-52] org.apach ...

  4. HTML5 canvas炫酷棱镜效果的幻灯片特效

    这是一款效果很炫酷华丽的HTML5 canvas带棱镜效果的幻灯片特效. 这个特效在每个幻灯片的前面放置一个图形.并将图形制作为三棱镜效果.它底下的幻灯片图片会被"折射"到棱镜上面 ...

  5. 主程的晋升攻略(3):IP、DNS和CDN

    有段时间我面试程序猿时,喜欢问这个问题:局域网IP有哪些IP段?由这个问题再追问NAT(网络地址转换). 为什么不是每一个设备一个公网IP? 先说个关于QQ的小故事,最早开发QQ时.小马哥他们也没想到 ...

  6. 二维码框架ZBarSDK的使用和自己定义二维码扫描界面方法

    假设你不知道ZBarSDK怎么用,请下载demo http://download.csdn.net/detail/u013686641/7858917 假设你已经配置好ZBarSDK .那么以下这个类 ...

  7. vim visual操作备忘

    visual模式下: jkl选中行 "+y 复制选中行

  8. Getting Started with MongoDB (MongoDB Shell Edition)

    https://docs.mongodb.com/getting-started/shell/ Overview Welcome to the Getting Started with MongoDB ...

  9. [湖南师大集训2018 7 26] hunger 解题报告 (SPFA)

    饿 (hungry.pas/c/cpp) [背景描述] 给出

  10. ViewPager中的数据更新

    getItemPosition(Object object) { return POSITION_NONE;} 出现的问题: 我希望能够通过调用 mAdapter.notifyDataSetChang ...