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 写的应用程序和用 . ...
随机推荐
- 杂项-IM:IM(即时通讯),一种基于互联网的即时交流消息的业务
ylbtech-杂项-IM:IM(即时通讯),一种基于互联网的即时交流消息的业务 即时通讯(Instant Messaging)是目前Internet上最为流行的通讯方式,各种各样的即时通讯软件也层出 ...
- System.Web.Mvc.HttpGetAttribute.cs
ylbtech-System.Web.Mvc.HttpGetAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, P ...
- UVA-307-Sticks-dfs+剪枝
George took sticks of the same length and cut them randomly until all parts became at most 50 units ...
- vue-select-lang
https://cli.vuejs.org/zh/guide/build-targets.html#%E5%BA%93 https://github.com/lipis/flag-icon-css
- 2day:Python基础
基础知识: 1.python文件的后缀名:.py 2 .Windows Python的执行方式:Python 解释器路径 py文件路径 例:C:\python3\python.exe d:\1.py ...
- 纯CSS3实现图片展示特效
本文中要实现的一个纯CSS3的图片展示特效,以前只能用JavaScript实现,可想而知会受到多方面的限制,特别是性能.而今天我们将用简单的CSS3代码实现,你会发现它的动画效果在现代浏览器的帮助下无 ...
- 《DSP using MATLAB》Problem 8.33
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 操作系统-Windows操作系统的线程调度了解这些
Windows操作系统支持内核级线程,调度单位是线程,它采用基于动态优先级的,抢占式调度,并结合时间配额的调整来完成调度 一.几个前提知识点 就绪线程按优先级进入相应的就绪队列 系统总是选择优先级最高 ...
- 使用CEfSharp之旅(5)CEFSharp 隔离Cookie
原文:使用CEfSharp之旅(5)CEFSharp 隔离Cookie 版权声明:本文为博主原创文章,未经博主允许不得转载.可点击关注博主 ,不明白的进群191065815 我的群里问 https:/ ...
- vue:使用element-ui制作动态表格
参考; https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/dynamic-table/compon ...