WebService-CXF使用
一、SOAP和WSDL概念:
SOAP(Simple Object Access Protocol):简单对象访问协议
SOAP作为一个基于XML语言的协议用于在网上传输数据
SOAP=在Http的基础上+xml数据
SOAP是基于http的
WSDL(WebService Description Language):web 服务描述语言,就是一个xml文档,用于描述当前服务的一些信息(服务名称、服务的发布地址、服务提供的方法、方法的参数类型、方法的返回值类型等)。
二、apache CXF入门
官网:cxf.apache.org下载CXF的开发包:
服务端开发:
第一步:创建动态web项目
第二步:导入CXF相关jar包
第三步:在web.xml中配置CXF框架提供的一个Servlet
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>crm</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- CXF Servlet -->
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<!-- needed for ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:cxf.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
第四步:在类路径下提供cxf.xml
<?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:core="http://cxf.apache.org/core"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.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" />
</beans>
第五步:开发一个接口和实现类
第六步:在cxf.xml中注册服务
客户端开发
第一步:创建Java项目并导入CXF相关jar包
第二步:使用wsimport或者CXF提供wsdl2java生成本地代码,只需要生成接口文件
wsdl2java 工具:此工具位于cxf_home/bin目录下,
它包含以下参数:
-d:指定代码生成的目录
-p:指定生成的新的包结构
第三步:将接口文件复制到项目中
第四步:提供spring配置文件,注册客户端代理对象
第五步:读取spring配置文件,创建spring工厂,从工厂中获取代理对象,实现远程调用
WebService-CXF使用的更多相关文章
- 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 写的应用程序和用 . ...
- WebService CXF知识总结
2018-10-23 <wsdl:service name="Iptv3aBasicService"> 客户端client信息,CXF会生成一个名为Iptv3ABasi ...
- WebService—CXF整合Spring实现接口发布和调用过程
一.CXF整合Spring实现接口发布 发布过程如下: 1.引入jar包(基于maven管理) <!-- cxf --> <dependency> <groupId> ...
- WebService—CXF—实现接口发布和客户端调用
(一)接口发布的几种方式 定义接口: @WebService(targetNamespace="http://www.itfad.net/queryUser") public in ...
- webservice -- cxf客户端调用axis2服务端
背景: 有个项目, 需要由第三方提供用户信息, 实现用户同步操作, 对方给提供webservice接口(axis2实现)并也使用axis2作主客户端调用我方提供的webservice接口 起初, 由于 ...
- webservice CXF 相关面试题
Web Service的优点(1) 可以让异构的程序相互访问(跨平台)(2) 松耦合(3) 基于标准协议(通用语言,允许其他程序访问) 1:WEB SERVICE名词解释.JSWDL开发包的介绍.JA ...
- WebService CXF Spring
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...
- Webservice(CXF) 、 POI(excel)操作部署到weblogic上冲突解决
这几日把webservice和POI 操作部署到WebLogic上,问题重重,有各种冲突. 部署到tomcat上没有问题 版本: jdk:6 tomcat:6 weblogic:10.3.3 cxf: ...
随机推荐
- codechef Transform the Expression 转换成逆波兰式
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/.未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- 安装最新版的wampserver,可以兼容php5和php7
本文介绍的wamp是Windows+Apache+MySQL+PHP+phpMyAdmin,主要应用于开发环境[一键安装包,简单好用]. 这是运行在Windows系统下的官方安装包,可以快速的搭建属于 ...
- python中模块与包的概念
在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护.为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就相对较少,很多 ...
- CentOS 7安装简介及基本操作
计算机基本概念: 1.计算机硬件组成: 2.计算机系统结构: 3.操作系统的功能:硬件驱动.进程管理.内存管理.网络管理.安全管理.文件管理等. 4.OS通用目的的软件程序:用户<-->应 ...
- 十三、IntelliJ IDEA 中的版本控制介绍(下)
我们已经简单了解了 IntelliJ IDEA 的版本控制机制,那么接下来,就让我们一起看看在 IntelliJ IDEA 中进行具体的版本控制操作. 标注1:Checkout from Versio ...
- 《Inetnet History,Technology and Security》学习笔记
前言 本文为观看Cousera的Michigan<Internet History, Technology and Security>教程的个人学习笔记,包括了每个week的概要和个人感想 ...
- C#串口通讯
本文提供一个用C#实现串口通讯实例,亲自编写,亲测可用! 开发环境:VS2008+.net FrameWork3.5(实际上2.0应该也可以) 第一步 创建一个WinForm窗体,拉入一些界面元素 重 ...
- Gradle Goodness: Profiling Information
If we want to know more about how much time is spent in tasks we can use the --profile command-line ...
- weex图片加载更多方法loadmore的使用
首先,放一个weex中loadmore使用的demo,可以看一下http://dotwe.org/vue/8dd2a10c69e149ae8971f8298cc8bebf 1.在list标签上添加 @ ...
- 20181030noip模拟赛T1
YY的矩阵 YY有一个大矩阵(N*M), 矩阵的每个格子里都有一个整数权值W[i,j](1<=i<=M,1<=j<=N) 对于这个矩阵YY会有P次询问,每次询问这个大矩阵的一个 ...