这个是配置带有接口的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.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://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/bye
implementor:指定具体的服务的类
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.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://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/bye
implementor:指定具体的服务的类
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 {

    @Override
public String sayBye(String name) {
// TODO Auto-generated method stub
return 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);
}
}

day63-webservice 08.在web项目中配置带有接口的webservice服务的更多相关文章

  1. web项目中配置多个数据源

    web项目中配置多个数据源 spring + mybatis 多数据源配置有两种解决方案 1.配置多个不同的数据源,使用一个sessionFactory,在业务逻辑使用的时候自动切换到不同的数据源,  ...

  2. 如何在web项目中配置Spring的Ioc容器

    在web项目中配置Spring的Ioc容器其实就是创建web应用的上下文(WebApplicationContext) 自定义要使用的IoC容器而不使用默认的XmlApplicationContext ...

  3. Log4j2在WEB项目中配置

    最近决定在新WEB项目中使用新的日志系统Log4j2. 官方介绍和学习文档网址为http://logging.apache.org/log4j/2.x/ 首先在WEB项目中引入以下几个jar包: ① ...

  4. 转载 Log4j2在WEB项目中配置

    最近决定在新WEB项目中使用新的日志系统Log4j2. 官方介绍和学习文档网址为http://logging.apache.org/log4j/2.x/ 首先在WEB项目中引入以下几个jar包: ① ...

  5. 如何在Web项目中配置Spring MVC

    要使用Spring MVC需要在Web项目配置文件中web.xml中配置Spring MVC的前端控制器DispatchServlet <servlet> <servlet-name ...

  6. 在web项目中配置log4j

    在web.xml中添加如下代码 <context-param> <param-name>contextConfigLocation</param-name> < ...

  7. 在web项目中发布jaxws

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

  8. 在web项目中使用cxf开发webservice,包含spring支持

    本文主要介绍了,如何使用cxf内置的例子,学会开发webserivce,在web项目中使用,且包含spring支持. webserivce的开发可以使用cxf或者axis,好像还有httpclient ...

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

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

随机推荐

  1. 前端-Vue学习思维导图笔记

    看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记有vue结构分析,JS基础,JQ,JS高级,Angular,git等等

  2. Android开发之拍照功能实现

    参考链接:http://www.linuxidc.com/Linux/2013-11/92892p3.htm 原文链接:http://blog.csdn.net/tangcheng_ok/articl ...

  3. HDU_5810_数学,概率,方差

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5810 大意:将n个球往m个盒子中投,每个球被投入每个盒子的概率相等,求方差. 看题解说,这是二项分布( ...

  4. Oracle中REGEXP_SUBSTR函数

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...

  5. 初识cocos creator的一些问题

    本文的cocos creator版本为v1.9.01.color赋值cc.Label组件并没有颜色相关的属性,但是Node有color的属性. //如果4个参数,在ios下有问题let rgb = [ ...

  6. react-router @4用法整理

    在React Router 3上写了一篇文章后不久,我第一次在React Rally 2016上遇到了Michael Jackson.Michael是React Router和Ryan Florenc ...

  7. 01 DOS常用命令

    有时候没有可视化窗口,命令行对文件进行操作更方便快捷 cmd 命令弹出 dir 查看当前所在目录下的文件 ctrl+c 退出 \a 显示隐藏文件 cd /改变到根目录 dir /a 显示隐藏文件 di ...

  8. eas源码示例1

    EditUI:  this.kdtEntrys.getRow(0).getCell(1).setValue("这个是第一行的第1个单元格的值");  public void loa ...

  9. swift-导航栏添加自定义返回按钮

    //1.添加返回按钮 func addBackBtn(){ let leftBtn:UIBarButtonItem=UIBarButtonItem(title: "返回", sty ...

  10. 关于如何利用js判断IE浏览器各种版本问题

    <!--[if IE 6]> IE 浏览器版本 6 <![endif]-->   <!--[if IE 7]> IE 浏览器版本 7 <![endif]--& ...