webService cxf学习
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接口
- @WebService
- public interface IHelloWorld {
- //@WebParam给参数命名,提高可代码可读性。此项可选
- blic String sayHi(@WebParam(name="text") String text);
- }
通过注解@WebService申明为webservice接口
第二步,实现WebService接口
- @WebService
- public class HelloWorldImpl implements IHelloWorld {
- public String sayHi(String name) {
- System.out.println("sayHello is called by " + name);
- return "Hello " + name;
- }
- }
第三步,创建服务端
- public class Server {
- private Server(){
- IHelloWorld helloWorld = new HelloWorldImpl();
- //创建WebService服务工厂
- JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
- //注册WebService接口
- factory.setServiceClass(IHelloWorld.class);
- //发布接口
- factory.setAddress("http://localhost:9000/HelloWorld");
- factory.setServiceBean(helloWorld);
- //创建WebService
- factory.create();
- };
- public static void main(String[] args) throws InterruptedException{
- //启动服务端
- new Server();
- System.out.println("Server ready...");
- //休眠一分钟,便于测试
- Thread.sleep(1000*60);
- System.out.println("Server exit...");
- System.exit(0);
- }
- }
第四步,创建客户端
- public class Client {
- private Client(){};
- public static void main(String[] args){
- //创建WebService客户端代理工厂
- JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
- //注册WebService接口
- factory.setServiceClass(HelloWorld.class);
- //设置WebService地址
- factory.setAddress("http://localhost:9000/HelloWorld");
- IHelloWorld iHelloWorld = (IHelloWorld)factory.create();
- System.out.println("invoke webservice...");
- System.out.println("message context is:"+iHelloWorld.sayHi("
- Josen"));
- System.exit(0);
- }
- }
4、 首先,运行服务端程序
其次,打开浏览器,在地址栏中输入http://localhost:9000/HelloWorld?wsdl
5、当你运行服务端时,其他原有的程序报错了。比如:javax.servlet-api 读不到了 ,读了geronimo-servlet包中的javax-servlet。。
在pom.xml里换个位置就行了。程序喜欢读前边的那个。(纠结好久TT)
webService cxf学习的更多相关文章
- WebService CXF学习:复杂对象传递(List,Map)
转自:https://blog.csdn.net/z69183787/article/details/35988335 第一步:创建存储复杂对象的类(因为WebServices的复杂对象的传递,一定要 ...
- WebService基础学习
参考 WebService基础学习(一)—基础知识:http://www.cnblogs.com/yangang2013/p/5708647.html WebService基础学习(二)—三要素:ht ...
- WebService基础学习(三)—CXF
一.什么是CXF? Apache CXF = Celtix + Xfire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF.Apache ...
- CXF学习(4) 处理无法自动转换的复合数据类型
只贴出服务端代码 1.Service接口类 package com.test.hello; import java.util.Map; import javax.jws.WebService; imp ...
- CXF学习(2) helloworld
0.新建一个项目取名wsserver. pom.xml 文件如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xml ...
- CXF学习 (1)
Axis(Apache) -> Axis2(Apache) XFire - > CXF (XFire+Celtrix) (Apache) CXF并不仅仅是Webservice框架,更号称是 ...
- webservice cxf error:类的两个属性具有相同名称 "password"
execption detail: Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.Servic ...
- WebService CXF调试常见报错及解决方案
1.CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory 解决方案:从apache-cxf/lib下寻找Wood ...
- webservice(CXF)基于3.1.1版本实例
引言 有没有一种办法可以实现跨应用程序进行通信和跨平台进行通信呢? 换句话说,就是有什么办法可以实现我的应用程序 A 可以和应用程序 B 进行通信呢? 或者说是,我用 Java 写的应用程序和用 . ...
随机推荐
- SpringCloud学习笔记(九):SpringCloud Config 分布式配置中心
概述 分布式系统面临的-配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务.由于每个服务都需要必要的配置信息才能运行,所以一套集中式的.动 ...
- hive 总结二
本文参考:黑泽君相关博客 本文是我总结日常工作中遇到的坑,结合黑泽君相关博客,选取.补充了部分内容. 查询函数(Hive高级) NVL(cloumn,replace_with) 如果cloumn为NU ...
- Appium测试过程中,建议使用谷歌输入法。用搜狗输入法报错报找不到元素,卡住
1. 手机使用谷歌输入法,在登录页面输入密码时输入数字时卡住报错 代码: 手机卡住 页面:看到页面上没有显示数字,所以卡住报错
- 7_3.springboot2.x启动配置原理_3.事件监听机制
事件监听机制配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListenerioc容器中的 ...
- Python中好用的模块们
目录 Python中好用的模块们 datetime模块 subprocess模块 matplotlib折线图 importlib模块 Python中好用的模块们 datetime模块 相信我们都使 ...
- springcloud系列13 config的客户端使用
config客户端的使用: 也是首先要引入依赖: <dependency> <groupId>org.springframework.cloud</groupId> ...
- java_网络编程之BS(web案例)
package BsServersocket; import java.io.*; import java.net.ServerSocket; import java.net.Socket; publ ...
- 2019-7-1-Roslyn-让编译时候-Message-内容默认输出
title author date CreateTime categories Roslyn 让编译时候 Message 内容默认输出 lindexi 2019-07-01 14:16:59 +080 ...
- 【学术篇】树上差分--洛谷3128最大流Max Flow
懒得贴题目,直接放不稳定的传送门(雾):点击前往暴风城(雾) 据说这题是BZOJ3490,但本蒟蒻没有权限╮(╯_╰)╭ 这题似乎就是裸树上差分... 对于树上(x,y)之间的路径上的点区间c[i]加 ...
- Python xlwt模块
Examples Generating Excel Documents Using Python’s xlwt Here are some simple examples using Python’s ...