本文链接:http://blog.csdn.net/kongxx/article/details/7525481

Apache CXF实战之一 Hello World Web Service

书接上文,下面看看CXF怎样和spring集成。

1.创建HelloWorld 接口类

  1. package com.googlecode.garbagecan.cxfstudy.helloworld;
  2. import javax.jws.WebMethod;
  3. import javax.jws.WebParam;
  4. import javax.jws.WebResult;
  5. import javax.jws.WebService;
  6. @WebService
  7. public interface HelloWorld {
  8. @WebMethod
  9. @WebResult String sayHi(@WebParam String text);
  10. }
package com.googlecode.garbagecan.cxfstudy.helloworld;

import javax.jws.WebMethod;

import javax.jws.WebParam;

import javax.jws.WebResult;

import javax.jws.WebService; @WebService

public interface HelloWorld {

@WebMethod

@WebResult String sayHi(@WebParam String text);

}

2.创建HelloWorld实现类 

  1. package com.googlecode.garbagecan.cxfstudy.helloworld;  
  2.   
  3. public class HelloWorldImpl implements HelloWorld {  
  4.   
  5.     public String sayHi(String name) {  
  6.         String msg = "Hello " + name + "!";  
  7.         return msg;  
  8.     }  
  9. }  
package com.googlecode.garbagecan.cxfstudy.helloworld;

public class HelloWorldImpl implements HelloWorld {
public String sayHi(String name) {
String msg = "Hello " + name + "!";
return msg;
}

}

3.修改web.xml文件

  1. <!DOCTYPE web-app PUBLIC  
  2.  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  3.  "http://java.sun.com/dtd/web-app_2_3.dtd" >  
  4.   
  5. <web-app>  
  6.   
  7.     <display-name>cxfstudy</display-name>  
  8.   
  9.     <servlet>  
  10.         <servlet-name>cxf</servlet-name>  
  11.         <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>  
  12.         <load-on-startup>1</load-on-startup>  
  13.     </servlet>  
  14.   
  15.     <servlet-mapping>  
  16.         <servlet-name>cxf</servlet-name>  
  17.         <url-pattern>/ws/</url-pattern>  
  18.     </servlet-mapping>  
  19.   
  20.     <listener>  
  21.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  22.     </listener>  
  23.       
  24.     <context-param>  
  25.         <param-name>contextConfigLocation</param-name>  
  26.         <param-value>classpath

    Apache CXF实战之二 集成Sping与Web容器的更多相关文章

    1. Apache CXF实战之四 构建RESTful Web Service

      Apache CXF实战之一 Hello World Web Service Apache CXF实战之二 集成Sping与Web容器 Apache CXF实战之三 传输Java对象 这篇文章介绍一下 ...

    2. CXF实战之在Tomcat中公布Web Service(二)

      服务接口及实现类请參考WebService框架CXF实战(一) 创建Maven Web项目,在pom.xml中加入CXF和Spring Web的引用,因为CXFServlet须要Spring Web的 ...

    3. CXF整合Sping与Web容器

      1.创建HelloWorld 接口类 package com.googlecode.garbagecan.cxfstudy.helloworld; import javax.jws.WebMethod ...

    4. WebService学习之旅(二)JAX-WS基于Web容器发布WebService

      在上节中我们定义Web服务接口和实现类后,调用Endpoint类的静态方法publish发布来webservice,这种方法使用起来虽然简单,但是对于一个企业级应用来说通常对外提供的服务可能不止一个, ...

    5. Apache CXF 103 CXF Basics - partial

      本Spike记录中内容,如无特别指出,均引用[1]. 0 引言 0.1 基本的Web服务术语 XML 业界的结构化交换信息表示的事实上的标准. XML namespace是在XML文档中提供唯一的命名 ...

    6. [CXF REST标准实战系列] 二、Spring4.0 整合 CXF3.0,实现测试接口(转)

      转自:[CXF REST标准实战系列] 二.Spring4.0 整合 CXF3.0,实现测试接口 文章Points: 1.介绍RESTful架构风格 2.Spring配置CXF 3.三层初设计,实现W ...

    7. 使用Apache CXF和Spring集成创建Web Service(zz)

      使用Apache CXF和Spring集成创建Web Service 您的评价:       还行  收藏该经验       1.创建HelloWorld 接口类 查看源码 打印? 1 package ...

    8. Spring 4 集成Apache CXF开发JAX-RS Web Service

      什么是JAX-RS 在JSR-311规范中定义,即Java API for RESTful Web Services,一套Java API,用于开发 RESTful风格的Webservice. 工程概 ...

    9. [CXF REST标准实战系列] 二、Spring4.0 整合 CXF3.0,实现测试接口

      Writer:BYSocket(泥沙砖瓦浆木匠) 微博:BYSocket 豆瓣:BYSocket Reprint it anywhere u want. 文章Points: 1.介绍RESTful架构 ...

    随机推荐

    1. js实现数组的去重

      function filterRepat(arr){ if(Array.isArray(arr) && arr.length){ var arr = arr.filter(functi ...

    2. 关于js里的document.compatmode

      document.compatmode为获取页面的渲染模式. 其中有两个渲染模式 1.CSS1Compat(标准模式).浏览器宽度:document.documentElement.clientHei ...

    3. swift语言点评五-Function

      一.函数类型 Every function in Swift has a type, consisting of the function’s parameter types and return t ...

    4. BZOJ3796 Mushroom追妹纸(二分答案+后缀数组+KMP)

      求出一个串使得这个串是\(s1,s2\)的子串.串中不包含\(s3\). 如果没有这个\(s3\)就可以二分答案,然后height小于二分值分一组.看看每组里是不是出现过\(s1,s2\)的后缀.判断 ...

    5. luogu P2664 树上游戏(点分治)

      点分治真是一个好东西.可惜我不会 这种要求所有路经的题很可能是点分治. 然后我就不会了.. 既然要用点分治,就想,点分治有哪些优点?它可以\(O(nlogn)\)遍历分治树的所有子树. 那么现在的问题 ...

    6. jsp页面跳转的路径问题

      <form class="box login" action="/graduation_system/BServlet" method="pos ...

    7. 转:强制Visual Studio以管理员身份运行

      Windows 8的一个既安全又蛋疼之处是UAC的行为被改变了.以往在Windows 7中,只要关闭了UAC,自己的帐号又是本机管理员组的,任何程序都会以管理员身份启动.然而,在Windows 8上, ...

    8. Qt之表单布局(QFormLayout)

      简述 QFormLayout管理输入型控件和关联的标签组成的那些Form表单. QFormLayout是一个方便的布局类,其中的控件以两列的形式被布局在表单中.左列包括标签,右列包含输入控件,例如:Q ...

    9. layDate1.0正式公布,您一直在寻找的的js日期控件

      你是时候换一款日期控件了,而layDate很愿意和您成为工作伙伴.她正致力于成为全球最高大上的web日期支撑,为国内外全部从事web应用开发的同仁提供力所能及的动力.她基于原生JavaScript精心 ...

    10. CentOS-6.4-minimal版中源代码安装MySQL-5.5.38

      完整版见https://jadyer.github.io/2014/09/29/centos-install-mysql/ /** * CentOS-6.4-minimal版中源代码安装MySQL-5 ...