这个是配置带有接口的WebService的服务。

http://localhost:8080/cxf-web-server/service

带有接口的实现类也给它做好了.jaxws:endpoint是用在类上,jaxws:server是用在接口上.这就是带有接口的WebService.

<?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:jaxws="http://cxf.apache.org/jaxws"xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsdhttp://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"><!-- 引入CXF Bean定义如下,早期的版本中使用 --><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" /><!-- =========================配置类的形式webservice服务==================================address:tomcat的host http://ip:port/projectName/service/后面的一端路径implementor:指定具体的服务的类--><!--  <jaxws:endpoint id="hello" address="/hello" implementor="com.rl.web.server.HelloService"> --><!-- 输入拦截器,打印输入的消息 --><!--  <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>--><!-- =======================配置带有接口的webservice服务=========================================address:tomcat的host http://ip:port/projectName/service/后面的一端路径http://ip:port/projectName/service/byeimplementor:指定具体的服务的类serviceClass:服务接口的类--><jaxws:server address="/bye" serviceClass="com.rl.web.server.inter.ByeInter">     <!-- 这里不是指定实例,而是指定实现类的类服务接口的实现类--><jaxws:serviceBean><bean class="com.rl.web.server.inter.ByeInterImpl"></bean></jaxws:serviceBean><!-- 输入拦截器,打印输入的消息 --> <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:server>
</beans>

<?xml version="1.0" encoding="UTF-8"?> <web-app  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><!-- 使用Spring的监听器 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class><!-- 初始化Spring的容器,cxf.xml本身就是一个Spring的容器.可以把cxf.xml作为Spring的容器进行加载. --> <!-- 能加载Spring文件的类,这个类叫什么? --></listener><context-param><param-name>contextConfigLocation</param-name><!-- param-name不能再指定config-location,而是要指定ContextLoaderListener里面读取Spring文件的那个Key --><param-value>classpath:cxf.xml</param-value></context-param><servlet><servlet-name>cxf</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class><!--  <init-param><param-name>config-location</param-name><param-value>classpath:cxf.xml</param-value></init-param><load-on-startup>1</load-on-startup>--></servlet><servlet-mapping><servlet-name>cxf</servlet-name><url-pattern>/service/*</url-pattern>  <!-- 拦截这种请求 --></servlet-mapping>
</web-app>

<?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:jaxws="http://cxf.apache.org/jaxws"xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsdhttp://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"><!-- 引入CXF Bean定义如下,早期的版本中使用 --><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" /><!-- =========================配置类的形式webservice服务==================================address:tomcat的host http://ip:port/projectName/service/后面的一端路径implementor:指定具体的服务的类--><!--  <jaxws:endpoint id="hello" address="/hello" implementor="com.rl.web.server.HelloService"> --><!-- 输入拦截器,打印输入的消息 --><!--  <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>--><!-- =======================配置带有接口的webservice服务=========================================address:tomcat的host http://ip:port/projectName/service/后面的一端路径http://ip:port/projectName/service/byeimplementor:指定具体的服务的类serviceClass:服务接口的类--><jaxws:server address="/bye" serviceClass="com.rl.web.server.inter.ByeInter"><!-- 这里不是指定实例,而是指定实现类的类服务接口的实现类--><jaxws:serviceBean><bean class="com.rl.web.server.inter.ByeInterImpl"></bean></jaxws:serviceBean><!-- 输入拦截器,打印输入的消息 --><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:server>
</beans>

package com.rl.web.server.inter;import javax.jws.WebService;@WebService
public interface ByeInter {public String sayBye(String name);    }

package com.rl.web.server.inter;public class ByeInterImpl implements ByeInter {@Overridepublic String sayBye(String name) {// TODO Auto-generated method stubreturn name + " bye";}}

package com.rl.cxf.web.client;import com.rl.web.inter.ByeInter;
import com.rl.web.inter.ByeInterService;public class WebInterClient {public static void main(String[] args) {ByeInterService  bs = new ByeInterService();ByeInter bi = bs.getByeInterPort();String result = bi.sayBye("八戒");System.out.println(result);}
}

转载于:https://www.cnblogs.com/ZHONGZHENHUA/p/7682192.html

day63-webservice 08.在web项目中配置带有接口的webservice服务相关推荐

  1. 详解log4j2(下) - Log4j2在WEB项目中配置

    官方介绍和学习文档网址为http://logging.apache.org/log4j/2.x/ 首先在WEB项目中引入以下几个jar包: ① log4j-api-2.4.1.jar ② log4j- ...

  2. jax-ws开发的webservice集成到web项目中

    2019独角兽企业重金招聘Python工程师标准>>> 前提条件: 1.官网下载jax-ws 网址:http://jax-ws.java.net 2.jdk版本1.5以上 1.新建一 ...

  3. Spring-Spring Web项目中配置使用Log4j 2

    Log4j 2概述 为什么要使用Log4j 2 Spring中配置Log4j 2 添加Maven依赖 配置webxml 配置Log4j 2 使用Log4j 2 Log4j 2概述 请查看另外一篇博文L ...

  4. 不使用框架的web项目中配置log4j

    在不使用框架的时候,一般使用监听器或者Servlet来初始化log4j进行启动,这里我使用Servlet,代码入下: import java.io.File; import java.io.IOExc ...

  5. 在maven web项目中配置log4j打印日志及Mybatis sql语句

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wei542657623/article/details/51591736 1 添加依赖 在pom.x ...

  6. 在web项目中发布jaxws

    概述 在web项目中发布基于jaxws的webservice. 参考文章:用JAX-WS在Tomcat中发布WebService 参考文章说,如果不是servlet3.0及以上,需要配置servlet ...

  7. SpringMVC,MyBatis项目中兼容Oracle和MySql的解决方案及其项目环境搭建配置、web项目中的单元测试写法、HttpClient调用post请求等案例

     要搭建的项目的项目结构如下(使用的框架为:Spring.SpingMVC.MyBatis): 2.pom.xml中的配置如下(注意,本工程分为几个小的子工程,另外两个工程最终是jar包): 其中 ...

  8. java web access_Java Web项目中连接Access数据库的配置方法

    本文是对前几天的"JDBC连接Access数据库的几种方式"这篇的升级.因为在做一些小项目的时候遇到的问题,因此才决定写这篇博客的.昨天已经将博客公布了.可是后来经过一些验证有点问 ...

  9. JAVA Web项目中所出现错误及解决方式合集(不断更新中)

    JAVA Web项目中所出现错误及解决方式合集 前言 一.几个或许会用到的软件下载官网 二.Eclipse的[preferences]下没有[sever]选项 三.Tomcat的安装路径找不到 四.T ...

最新文章

  1. 反向词典_根据描述查找词语
  2. 有奖话题讨论:你的互联网从业故事
  3. 优先级调度和运行前调度的比较
  4. markdown希腊字母
  5. 数据结构:Binary and other trees(数据结构,算法及应用(C++叙事描述语言)文章8章)...
  6. java中怎样定义实数_Java Math 类中的新功能,第 1 部分: 实数
  7. calendar类_带有时区的字符怎样转换为时间及Java 8中日期 与 Calendar 转换
  8. python定时任务_Python定时任务(上)
  9. 企业微信添加机器人播报天气
  10. python单选题库答案_大学慕课2020用Python玩转数据题库及答案
  11. 我对于男人喜欢喷香水是觉得很恶心的一件事
  12. ODBC数据源的作用及配置
  13. macbook pro M1Pro安装java开发环境,jdk和eclipse安装包快速下载方式
  14. c语言是非结构化程序语言_1、C语言是一种结构化程序设计语言
  15. 一文了解新营销,数字经济时代如何以个人为中心重建品牌?
  16. 常见音频格式大盘点分析
  17. 7z解压crc错误_rar文件解压缩失败解压末端出现错误的解决方法
  18. php中根据二维数组某个字段的值查找对应的一维数组
  19. 中国科学院自动化所2020年考博经验分享
  20. 2021-2027全球与中国R717制冷剂市场现状及未来发展趋势

热门文章

  1. Android(java)学习笔记164:开发一个多界面的应用程序之不同界面间互相传递数据(短信助手案例)...
  2. struts配置通配符*来匹配方法,实现动态调用
  3. 学习mfc的一些方法
  4. 工作流添加跟踪后,实例一启动就会自动关闭
  5. caioj1495: [视频]基于连通性状态压缩的动态规划问题:Formula 2
  6. sqlserver中创建包含事务的存储过程
  7. Python自学之路——Python基础(四)内置函数
  8. Centos 6.5 X64 环境下编译 hadoop 2.6.0 --已验证
  9. scala Ordering
  10. C++之C/C++内存对齐