这个是配置带有接口的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. 基于 CC2530 的温度采集系统(未定稿)

    前言 最近在自学 Zigbee,每天的主要是任务是:看博客,看 CC2530 的 datasheet 和实践,熟悉片上的 SFR 以及控制板子. 学和做内容包括:IO.外部中断.Timer1/3/4. ...

  2. [转]VIM字符替换

    语法为 :[addr]s/源字符串/目的字符串/[option] 全局替换命令为::%s/源字符串/目的字符串/g [addr] 表示检索范围,省略时表示当前行. 如:"1,20" ...

  3. java这个404你能解决吗?

    前言 本文首发于公众号[我的小碗汤]本公众号免费提供csdn下载服务,海量IT学习资源,如果你准备入IT坑,励志成为优秀的程序猿,那么这些资源很适合你,包括但不限于java.go.python.spr ...

  4. cocos ios Label组件问题

    软件:cocos creator v1.9.0 开发的过程中,一直在web上预览,Label组件显示一直没问题.在打包到ios上时,出现问题了: Label组件: 当我们缩小字体,发现没问题了,当我们 ...

  5. vue 导航菜单默认子路由

    export default new Router({ routes: [ { path: '/', name: 'index', component: index, children: [ { pa ...

  6. Python检测删除你的好友-wxpy模块(发送特殊字符式)

    下面是代码: from wxpy import *import timeprint("本软件采用特殊字符检测,即对方收不到任何信息!")print("或许某个版本微信就会 ...

  7. Codeforces 816C/815A - Karen and Game

    传送门:http://codeforces.com/contest/816/problem/C 本题是一个模拟问题. 有一个n×m的矩阵.最初,这个矩阵为零矩阵O.现有以下操作: a.行操作“row  ...

  8. 1、springboot+mybatis+zookeeper+dubbox+maven+pagehelper

    一.创建普通的maven的web项目 2.配置KD42WF_Part1下的pom.xml <?xml version="1.0" encoding="UTF-8&q ...

  9. 学习EXTJS6(3)基本概念

    ExtJS不再纠缠HTML和CSS上.概念和传统的程序相近.如面板panel,布局Layout.组件Component等等. 1.渲染Render:ExtJS页面在浏览器中装载完成后完全展现出来的一个 ...

  10. 如何用PYTHON的CGIHTTPSERVER模块模拟POST请求?

    这次又要逼真一点点,可以弄POST请求啦. 在WEB根目录下新建cgi-bin目录(据说是规模要求),然后运行命令: python -m CGIHTTPServer CGI-BIN目录下,form.p ...