maven版cxf集合spring开发服务端(二)
一、新建一个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开发服务端(二)的更多相关文章
- maven版cxf集合jetty开发服务端(一)
一.首先新建一个maven项目 二.pom.xml引入依赖 <dependency> <groupId>org.apache.cxf</groupId> <a ...
- WebService-03-使用CXF开发服务端和客户端
写在前面的话 前面两节说了使用Java提供的包开发服务端和客户端,现在使用CXF来开发,CXF提供了两个类发而服务,一个是ServerFactoryBean,另一个是JaxWsServerFactor ...
- webservice -- cxf客户端调用axis2服务端
背景: 有个项目, 需要由第三方提供用户信息, 实现用户同步操作, 对方给提供webservice接口(axis2实现)并也使用axis2作主客户端调用我方提供的webservice接口 起初, 由于 ...
- JSR-303 Bean Validation 介绍及 Spring MVC 服务端参数验证最佳实践
任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用很多时候同样的数据验证逻辑会出现在不同的层,这样 ...
- Spring Cloud 服务端注册与客户端调用
Spring Cloud 服务端注册与客户端调用 上一篇中,我们已经把Spring Cloud的服务注册中心Eureka搭建起来了,这一章,我们讲解如何将服务注册到Eureka,以及客户端如何调用服务 ...
- JSR-303 Bean Validation 介绍及 Spring MVC 服务端验证最佳实践
任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用在很多时候,同样的数据验证逻辑会出现在不同的层, ...
- 用beego开发服务端应用
用beego开发服务端应用 说明 Quick Start 安装 创建应用 编译运行 打包发布 代码生成 开发文档 目录结构说明 使用配置文件 beego默认参数 路由设置 路由的表述方式 直接设置路由 ...
- 基于Apache CXF的Web Service服务端/客户端
转自:https://www.aliyun.com/zixun/wenji/1263190.html CXF服务端: package com.sean.server; import javax.jws ...
- Spring+SpringMVC+Mybatis+Maven+CXF+WebService整合之服务端
WebService服务端项目结构: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h ...
随机推荐
- [转]触发fullgc的条件
良好的状态是:minor gc比较多 full gc 比较少 因为fullgc时间比较慢,而且会占用CPU的时间片. 不好的状态是:minor gc比较少 full gc 比较多 这样程序就一直卡在f ...
- conn (php)
<?php$host="localhost";$db_user="root"; //数据库用户$db_pass=""; //数据库密码 ...
- soundtouch change pitch matlab implementation
function output = changePitch(input, pitchInSemitones) % one octave is 12 semitones octave = pitchIn ...
- c#中的强类型、弱类型和泛型
强类型和弱类型的变量都有两个属性:类型和值. 强类型的变量类型是不能改变的,弱类型的变量类型是随需改变的,这是强弱的真正含义. 我们在编写c#代码时,变量类型是明确的,不可更改的,如string就是s ...
- [HDU4609] 3-idiots - 多项式乘法,FFT
题意:有\(n\)个正整数,求随机选取一个3组合,能构成三角形的概率. Solution: 很容易想到构造权值序列,对其卷积得到任取两条边(可重复)总长度为某数时的方案数序列,我们希望将它转化为两条边 ...
- 【转载】Java嵌入Pig编程
转自:https://wiki.apache.org/pig/EmbeddedPig Embedding Pig In Java Programs Sometimes you want more co ...
- C++ vector的用法(转)
原文链接:https://blog.csdn.net/qinyuehong/article/details/92837359
- codeforces 1284D. New Year and Conference(线段树)
链接:https://codeforces.com/problemset/problem/1284/D 题意:有n场讲座,有两个场地a和b,如果在a场地开讲座则需要占用[sai,eai],在b场地开讲 ...
- 前后端分离构架 与 json ajax简介
前后端分离 传统开发方式 曾几何时,JSP和Servlet为Java带来了无限风光,一时间大红大紫,但随着互联网的不断发展,这样的开发方式逐渐显露其弊端,在移动互联网炙手可热的今天,应用程序对于后台服 ...
- MySql -- primary key主键约束
4.primary key主键约束 在一张表中: 1) 主键约束是 NOT NULL.UNIQUE唯一的记录. 2) 主键约束必须是唯一的值. 3) 主键约束列不能包含 NULL 值. 注意:每个表都 ...