1、首先去官网下载cxf包

http://archive.apache.org/dist/cxf/

记住要选.zip结尾 大概40兆的样子

2、把上边的包都放项目里。如果你用的jeecg框架,那它自带,不过少了一个jetty的包。记得在pom.xml中加入

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency> 3、http://blog.csdn.net/oneGeng/article/details/5979442 这里面讲的很详细
第一步:新建一个webservice接口 
  1. @WebService
  2. public interface IHelloWorld {
  3. //@WebParam给参数命名,提高可代码可读性。此项可选
  4. blic String sayHi(@WebParam(name="text") String text);
  5. }
   通过注解@WebService申明为webservice接口 
   第二步,实现WebService接口 
  1. @WebService
  2. public class HelloWorldImpl implements IHelloWorld {
  3. public String sayHi(String name) {
  4. System.out.println("sayHello is called by " + name);
  5. return "Hello " + name;
  6. }
  7. }
   第三步,创建服务端 
  1. public class Server {
  2. private Server(){
  3. IHelloWorld helloWorld = new HelloWorldImpl();
  4. //创建WebService服务工厂
  5. JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
  6. //注册WebService接口
  7. factory.setServiceClass(IHelloWorld.class);
  8. //发布接口
  9. factory.setAddress("http://localhost:9000/HelloWorld");
  10. factory.setServiceBean(helloWorld);
  11. //创建WebService
  12. factory.create();
  13. };
  14. public static void main(String[] args) throws InterruptedException{
  15. //启动服务端
  16. new Server();
  17. System.out.println("Server ready...");
  18. //休眠一分钟,便于测试
  19. Thread.sleep(1000*60);
  20. System.out.println("Server exit...");
  21. System.exit(0);
  22. }
  23. }
    第四步,创建客户端 
  
  1. public class Client {
  2. private Client(){};
  3. public static void main(String[] args){
  4. //创建WebService客户端代理工厂
  5. JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
  6. //注册WebService接口
  7. factory.setServiceClass(HelloWorld.class);
  8. //设置WebService地址
  9. factory.setAddress("http://localhost:9000/HelloWorld");
  10. IHelloWorld iHelloWorld = (IHelloWorld)factory.create();
  11. System.out.println("invoke webservice...");
  12. System.out.println("message context is:"+iHelloWorld.sayHi("
  13. Josen"));
  14. System.exit(0);
  15. }
  16. }

4、 首先,运行服务端程序 
    其次,打开浏览器,在地址栏中输入http://localhost:9000/HelloWorld?wsdl

5、当你运行服务端时,其他原有的程序报错了。比如:javax.servlet-api 读不到了 ,读了geronimo-servlet包中的javax-servlet。。

在pom.xml里换个位置就行了。程序喜欢读前边的那个。(纠结好久TT)

webService cxf学习的更多相关文章

  1. WebService CXF学习:复杂对象传递(List,Map)

    转自:https://blog.csdn.net/z69183787/article/details/35988335 第一步:创建存储复杂对象的类(因为WebServices的复杂对象的传递,一定要 ...

  2. WebService基础学习

    参考 WebService基础学习(一)—基础知识:http://www.cnblogs.com/yangang2013/p/5708647.html WebService基础学习(二)—三要素:ht ...

  3. WebService基础学习(三)—CXF

    一.什么是CXF?      Apache CXF = Celtix + Xfire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF.Apache ...

  4. CXF学习(4) 处理无法自动转换的复合数据类型

    只贴出服务端代码 1.Service接口类 package com.test.hello; import java.util.Map; import javax.jws.WebService; imp ...

  5. CXF学习(2) helloworld

    0.新建一个项目取名wsserver. pom.xml 文件如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xml ...

  6. CXF学习 (1)

    Axis(Apache) -> Axis2(Apache) XFire - > CXF (XFire+Celtrix) (Apache) CXF并不仅仅是Webservice框架,更号称是 ...

  7. webservice cxf error:类的两个属性具有相同名称 "password"

    execption detail: Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.Servic ...

  8. WebService CXF调试常见报错及解决方案

    1.CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory 解决方案:从apache-cxf/lib下寻找Wood ...

  9. webservice(CXF)基于3.1.1版本实例

    引言 有没有一种办法可以实现跨应用程序进行通信和跨平台进行通信呢? 换句话说,就是有什么办法可以实现我的应用程序 A 可以和应用程序 B 进行通信呢? 或者说是,我用 Java 写的应用程序和用 . ...

随机推荐

  1. 杂项-IM:IM(即时通讯),一种基于互联网的即时交流消息的业务

    ylbtech-杂项-IM:IM(即时通讯),一种基于互联网的即时交流消息的业务 即时通讯(Instant Messaging)是目前Internet上最为流行的通讯方式,各种各样的即时通讯软件也层出 ...

  2. System.Web.Mvc.HttpGetAttribute.cs

    ylbtech-System.Web.Mvc.HttpGetAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, P ...

  3. UVA-307-Sticks-dfs+剪枝

    George took sticks of the same length and cut them randomly until all parts became at most 50 units ...

  4. vue-select-lang

    https://cli.vuejs.org/zh/guide/build-targets.html#%E5%BA%93 https://github.com/lipis/flag-icon-css

  5. 2day:Python基础

    基础知识: 1.python文件的后缀名:.py 2 .Windows Python的执行方式:Python 解释器路径  py文件路径 例:C:\python3\python.exe d:\1.py ...

  6. 纯CSS3实现图片展示特效

    本文中要实现的一个纯CSS3的图片展示特效,以前只能用JavaScript实现,可想而知会受到多方面的限制,特别是性能.而今天我们将用简单的CSS3代码实现,你会发现它的动画效果在现代浏览器的帮助下无 ...

  7. 《DSP using MATLAB》Problem 8.33

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  8. 操作系统-Windows操作系统的线程调度了解这些

    Windows操作系统支持内核级线程,调度单位是线程,它采用基于动态优先级的,抢占式调度,并结合时间配额的调整来完成调度 一.几个前提知识点 就绪线程按优先级进入相应的就绪队列 系统总是选择优先级最高 ...

  9. 使用CEfSharp之旅(5)CEFSharp 隔离Cookie

    原文:使用CEfSharp之旅(5)CEFSharp 隔离Cookie 版权声明:本文为博主原创文章,未经博主允许不得转载.可点击关注博主 ,不明白的进群191065815 我的群里问 https:/ ...

  10. vue:使用element-ui制作动态表格

    参考; https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/dynamic-table/compon ...