一、新建一个maven项目

二、pom.xml引入依赖

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>2.5.0</version>
</dependency>
<!-- 如果跑在tomcat下,下面可以不用 -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.5.0</version>
</dependency>

三、开发接口类

import javax.jws.WebService;

@WebService
public interface HelloWorld { String sayHi(String username);
}

四、开发实现类

import javax.jws.WebService;
import com.xie.ws.HelloWorld; @WebService(endpointInterface="com.xie.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld { public String sayHi(String username) {
System.out.println("Hello,"+username);
return "Hello,"+username;
} }

五、修改web.xml

<!-- 配置 Spring 配置文件的名称和位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/config/spring.xml</param-value>
</context-param>
<!-- 启动 IOC 容器的 ServletContextListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 配置字符集 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<!-- 这个设置很重要,那么我们的webservice的地址就是http://localhost:8080/项目/webservice/服务名 -->
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>

六、添加spring.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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"> <jaxws:endpoint id="helloWorld" implementor="com.xie.ws.impl.HelloWorldImpl" address="/helloWorld"/> <!--
<bean id="helloWordImpl" class="com.xie.ws.impl.HelloWordImpl"/>
<jaxws:endpoint id="helloWord" implementor="#helloWordImpl" address="/helloWord" />
--> </beans>

七、部署到tomcat启动后访问

  浏览器输入: http://localhost:8080/CxfWSServer/webservice/helloWorld?wsdl

maven版cxf集合spring开发服务端(二)的更多相关文章

  1. maven版cxf集合jetty开发服务端(一)

    一.首先新建一个maven项目 二.pom.xml引入依赖 <dependency> <groupId>org.apache.cxf</groupId> <a ...

  2. WebService-03-使用CXF开发服务端和客户端

    写在前面的话 前面两节说了使用Java提供的包开发服务端和客户端,现在使用CXF来开发,CXF提供了两个类发而服务,一个是ServerFactoryBean,另一个是JaxWsServerFactor ...

  3. webservice -- cxf客户端调用axis2服务端

    背景: 有个项目, 需要由第三方提供用户信息, 实现用户同步操作, 对方给提供webservice接口(axis2实现)并也使用axis2作主客户端调用我方提供的webservice接口 起初, 由于 ...

  4. JSR-303 Bean Validation 介绍及 Spring MVC 服务端参数验证最佳实践

    任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用很多时候同样的数据验证逻辑会出现在不同的层,这样 ...

  5. Spring Cloud 服务端注册与客户端调用

    Spring Cloud 服务端注册与客户端调用 上一篇中,我们已经把Spring Cloud的服务注册中心Eureka搭建起来了,这一章,我们讲解如何将服务注册到Eureka,以及客户端如何调用服务 ...

  6. JSR-303 Bean Validation 介绍及 Spring MVC 服务端验证最佳实践

    任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用在很多时候,同样的数据验证逻辑会出现在不同的层, ...

  7. 用beego开发服务端应用

    用beego开发服务端应用 说明 Quick Start 安装 创建应用 编译运行 打包发布 代码生成 开发文档 目录结构说明 使用配置文件 beego默认参数 路由设置 路由的表述方式 直接设置路由 ...

  8. 基于Apache CXF的Web Service服务端/客户端

    转自:https://www.aliyun.com/zixun/wenji/1263190.html CXF服务端: package com.sean.server; import javax.jws ...

  9. Spring+SpringMVC+Mybatis+Maven+CXF+WebService整合之服务端

    WebService服务端项目结构: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h ...

随机推荐

  1. AntDesign(React)学习-4 登录页面提交数据简单实现

    github代码:https://github.com/zhaogaojian/jgdemo 全国肺炎,过节期间没地方去在家学习antd. 一.感觉antd pro项目太庞大了,可以学习下结构和代码风 ...

  2. 01 : Java入门

    Java概述 Java之父·詹姆斯·高斯林(James Gosling) 1977年获得了加拿大卡尔加里大学计算机科学学士学位,1983年获得了美国卡内基梅隆大学计算机科学博士学位,毕业后到IBM工作 ...

  3. CSS 自适应导航菜单

    文章目录 以前我写了一篇关于如何为自适应网页制作教程手机导航菜单,现在我又摸索出一种无需JS脚本的自适应导航菜单,它采用纯粹的语义化HTML5标签来完成.该菜单可以左对齐,居中或右对齐,也不像上一种方 ...

  4. MySQL常用命令符

    收集于网络!!!! 解决字符乱码问题:显示汉语而非乱码:set names utf8: 修改新密码:update user set password=PASSWORD('新密码') where use ...

  5. msfconsole启动失败并报错`not_after=': bignum too big to convert into `long'的解决方法

    1.启动msfconsole失败并报如下错误: /usr/share/metasploit-framework/lib/msf/core/payload/android.rb:86:in `not_a ...

  6. SequoiaDB巨杉数据库入门:快速搭建流媒体服务器

    使用SequoiaDB的分布式文件系统搭建流媒体服务器 介绍 如今使用移动互联网的年轻人开始越来越多使用短视频展示自我,而流媒体则是支撑在线视频播放的核心技术.当我们开始构建流媒体站点时,往往面临最大 ...

  7. Web渗透测试思路整理

    信息收集: 域名/IP 子域名列表 whois: 注册地址,注册人,联系方式等 whois反查: 同ip有哪些站点(旁注),同一个注册人注册了哪些域名 社工注册人信息 指纹识别: 操作系统及版本 数据 ...

  8. EF的延迟加载LazyLoad

    延迟加载只对 关联/导航 属性(Navigation Property)有用,普通属性没有这个东西. 延迟加载是一条一条的读取属性,调用一次,读取一次. 条件: context.Configurati ...

  9. input:file上传文件类型(记录)

    imput 属性有以下几种: 1.type:input类型这就不多说了2.accept:表示可以选择的文件类型,多个类型用英文逗号分开,常用的类型见下表. <input id="fil ...

  10. KMP算法例题

    链接:https://codeforces.com/contest/1200/problem/E 题意:依次合并两个单词,每次合并将删去最长相同前后缀,输出结果. 思路:用kmp跑出每个需要被连接的单 ...