1.服务端和服务端引入相关cxf的jar包:

(2).采用导包方式:

2.服务端编写:

(1).定义接口:

(2).实现该接口,进行相应的业务逻辑:

(3).spring的配置文件编写:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:cxf="http://cxf.apache.org/core"
 5     xmlns:jaxws="http://cxf.apache.org/jaxws"
 6     xmlns:jaxrs="http://cxf.apache.org/jaxrs"
 7     xsi:schemaLocation="
 8         http://www.springframework.org/schema/beans
 9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://cxf.apache.org/core
11         http://cxf.apache.org/schemas/core.xsd
12         http://cxf.apache.org/jaxws
13         http://cxf.apache.org/schemas/jaxws.xsd
14         http://cxf.apache.org/jaxrs
15         http://cxf.apache.org/schemas/jaxrs.xsd
16         ">
17     <bean id="weatherService" class="cn.itcast.webservice.WeatherService"></bean>
18     <jaxws:server address="/weather">
19         <jaxws:serviceBean>
20             <ref bean="weatherService"/>
21         </jaxws:serviceBean>
22     </jaxws:server>
23
24 </beans>

这里xsd约束记得添加上,以及注册bean,以及jaxws:server的配置,别写成jaxrs:server了

(4)web.xml的配置:

1).简单版:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 5     id="WebApp_ID" version="2.5">
 6     <display-name>ws2803</display-name>
 7     <welcome-file-list>
 8         <welcome-file>index.jsp</welcome-file>
 9     </welcome-file-list>
10
11     <!-- spring监听器 -->
12     <listener>
13         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
14     </listener>
15     <!-- 配置sprnig的配置文件 -->
16     <context-param>
17         <param-name>contextConfigLocation</param-name>
18         <param-value>classpath:applicationContext.xml</param-value>
19     </context-param>
20     <!-- CXF核心控制器的配置 -->
21     <servlet>
22         <servlet-name>cxf</servlet-name>
23         <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
24     </servlet>
25     <servlet-mapping>
26         <servlet-name>cxf</servlet-name>
27         <url-pattern>/ws/*</url-pattern>
28     </servlet-mapping>
29 </web-app>

配置spring的基本配置与cxf的核心控制器的配置

2).与spring的过滤器整合方式:

                图 1

               图 2

(5)部署发布:

1).如果是web项目直接服务器发布就行:

2).java工程采用main函数方式:

(6).测试是否发布成功:

3.客户端编写:

(1).采用jdk自带的wsimport.exe工具解析文档说明书(上面的wsdl):

(2).复制client的src目录,然后进入该目录,使用wsimport命令解析成java文件

wsimport -s . http://localhost/ws2803/ws/weather?wsdl       
命令-s 解析到制定文件
命令. 指解析当当前文件

(3)spring中applicationContext.xml的配置,主要是客户端的配置,IWeatherService为解析出来的接口

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:cxf="http://cxf.apache.org/core"
 5     xmlns:jaxws="http://cxf.apache.org/jaxws"
 6     xmlns:jaxrs="http://cxf.apache.org/jaxrs"
 7     xsi:schemaLocation="
 8         http://www.springframework.org/schema/beans
 9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://cxf.apache.org/core
11         http://cxf.apache.org/schemas/core.xsd
12         http://cxf.apache.org/jaxws
13         http://cxf.apache.org/schemas/jaxws.xsd
14         http://cxf.apache.org/jaxrs
15         http://cxf.apache.org/schemas/jaxrs.xsd
16         ">
17
18     <jaxws:client id="weatherBean" address="http://localhost/ws2803/ws/weather?wsdl"
19         serviceClass="cn.itcast.webservice.IWeatherService">
20     </jaxws:client>
21 </beans>

(4).测试:

1).引入applicationContext.xml形式

2).采用注解方式:

转载于:https://www.cnblogs.com/jeffery336699/p/9289277.html

Spring+webservice(cxf框架)相关推荐

  1. 转载 WebService 的CXF框架 WS方式Spring开发

    WebService 的CXF框架 WS方式Spring开发 1.建项目,导包. 1 <project xmlns="http://maven.apache.org/POM/4.0.0 ...

  2. 系统开发系列 之MyEclipse创建WebService详细教程和调用教程(spring框架+maven+CXF框架)

    1 回顾 [系统开发系列 之MyEclipse创建WebService详细教程和调用教程]介绍了使用JWS实现WebService接口的发布和调用,主要涉及的点有: (1)MyEclipse点击Fil ...

  3. Spring整合CXF,发布RSETful 风格WebService

    这篇文章是承接之前CXF整合Spring的这个项目示例的延伸,所以有很大一部分都是一样的.关于发布CXF WebServer和Spring整合CXF这里就不再多加赘述了.如果你对Spring整合CXF ...

  4. wsld2java_脱离spring集成cxf(基于nutz框架)

    什么是webService cxf 简单的说就是实现webService的一个比较流行的框架 http://blog.sina.com.cn/s/blog_6182547f01017pak.html ...

  5. 分布式架构探索 - 2. WebService RPC框架之Apache CXF

    Apache CXF是一个开源的WebService RPC框架. 例子: 1. 新建一个maven web项目, 添加pom 如下: <?xml version="1.0" ...

  6. Maven项目集成cxf框架发布WebService

    关于Maven项目集成cxf框架发布和接收WebService 从网上找了很多,发现大多数都是类似"单机"版的发布,直到看了一篇博客,给我很大的启发. 在此感谢这位博客的作者:ht ...

  7. CXF框架发布WebService服务的例子

    1.CXF框架概念介绍 Apache CXF 是一个开源的 WebService 框架,CXF可以用来构建和开发 WebService,这些服务可以支持多种协议,比如:SOAP.POST/HTTP.H ...

  8. 采用CXF框架发布WebService

    1. CXF介绍 :soa的框架     * cxf 是 Celtrix (ESB框架)和 XFire(webserivice) 合并而成,并且捐给了apache       * CxF的核心是org ...

  9. CXF 框架webservice 概括与特点

    CXF是webservice的框架, CXF可以与spring进行快速无缝的整合.因为CXF可以在spring的配置文件中进行webservice的相关的配置. CXF可以灵活的部署在多方web容器中 ...

  10. 二、cxf框架实现REST风格http协议的WebService(JAX-RS标准)

    上一章我已经讲了cxf框架实现soap协议的WebService(JAX-WS的标准) 下面我开始讲第二种WebService的客户端和服务器的创建,利用 cxf框架和 REST风格http协议来实现 ...

最新文章

  1. 状态压缩dp(hdu2662)(我综合了一个人的解释和另一个人的代码)
  2. 微型计算机技术实验报告,微型计算机技术及应用实验报告.docx
  3. SegAttnGAN: Text to Image Generation with Segmentation Attention 论文解读
  4. 在Spring使用AWS SQS创建消息驱动Bean
  5. 上周热点回顾(2.25-3.3)
  6. linux ubuntu/centos相关收藏
  7. 汇编语言中sbb是什么意思_汇编语言的所有指令
  8. 关于Selenium2Library库导入PyCharm无法自动感知关键字的解决方法
  9. 4170万元人民币的 绿坝 花季护航 预装1年软件,到底值不值
  10. 《Java从入门到放弃》框架入门篇:在MyEclipse中创建SpringBoot项目
  11. IntelliJ IDEA自带接口测试工具
  12. 科技小科普】物联网的八大核心技术
  13. 私网ip和公网ip_详解
  14. Workbench网格分块分区划分 扫面、节点控制网格数的应用
  15. Flutter 图片选取 image_picker
  16. python 重试—retry库的使用和自定义超时retry
  17. 果壳网(guokr.com)发布了
  18. svn新建文件夹报405错误
  19. 《两种文化与科学革命》读后感
  20. 爬取隔壁杭电研究生导师信息

热门文章

  1. 游戏筑基开发之测试篇2(C语言)
  2. Docker详解(二)——Docker技术原理与架构
  3. 网络层QoS分类和标记字段详解
  4. hash通信(python多线程应用)采用md5加密
  5. HDOJ--1875--畅通工程再续
  6. iOS学习资源(五)
  7. django发送邮件结合itsdangerous+celery+redis
  8. CSS浮动元素的水平居中
  9. 华为ADSL路由设置
  10. CMOS checksum error-Defaults loaded 故障解决办法