1. 引入cxf的jar包
pom文件里面直接增加依赖
< dependency>
<groupId > junit</ groupId>
<artifactId > junit</ artifactId>
<version >4.11 </version >
<scope >test </scope >
</dependency >
<dependency >
<groupId >org.springframework </groupId >
<artifactId >spring- webmvc</ artifactId>
<version >4.0.0.RELEASE </version >
</dependency >
<dependency >
<groupId >org.apache.cxf </groupId >
<artifactId > apache-cxf </artifactId >
<version >2.4.3</version >
<type > pom</ type>
</dependency >

2. 配置web.xml文件
<? xml version= "1.0" encoding= "UTF-8" ?>
< web-app xmlns= "http://xmlns.jcp.org/xml/ns/javaee"

xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation= "http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version= "3.1" >

< display-name >Archetype Created Web Application </display-name >
< context-param >
<param-name >contextConfigLocation </param-name >
<param-value >classpath:config/spring/metadataWebService-spring.xml </param-value >
</context-param >
<listener >
<listener-class >org.springframework.web.context.ContextLoaderListener </listener-class >
</listener >
<servlet >
<servlet-name >CXFServlet </servlet-name >
<servlet-class >org.apache.cxf.transport.servlet.CXFServlet </servlet-class >
</servlet >
<servlet-mapping >
<servlet-name >CXFServlet </servlet-name >
<url-pattern >/services/* </url-pattern >
</servlet-mapping >
<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 >
</ web-app>

3. 配置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:context= "http://www.springframework.org/schema/context"
xmlns:jaxrs= "http://cxf.apache.org/jaxrs"
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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd" >
<!-- simpleWebService.xml配置文件 start -->
<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" />
<context:annotation-config />
<!-- SOAP 服务开放 -->
<bean id = "wSS4JInInterceptor" class= "org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor" >
<constructor-arg >
<!--
<map >
<entry key = "action" value= "UsernameToken" />
<entry key = "passwordType" value= "PasswordText" />
<entry key = "user" value= "cxfServer" />
<entry key = "passwordCallbackRef" value= "ss" />
</map >
-->
</constructor-arg >
</bean >
<bean id = "jaxWsServerFactoryBean" class= "org.apache.cxf.jaxws.JaxWsServerFactoryBean"
scope= "prototype" >
<property name = "inInterceptors">
<list >
<!-- <ref bean = "wSS4JInInterceptor" /> -->
</list >
</property >
</bean >
<bean id = "jaxWsWebServicePublisherBeanPostProcessor"
class= "org.apache.cxf.jaxws.spring.JaxWsWebServicePublisherBeanPostProcessor" >
<property name = "urlPrefix" value= "/" />
<property name = "prototypeServerFactoryBeanName" value= "jaxWsServerFactoryBean" />
</bean >
<!-- simpleWebService.xml配置文件 end-->
<!-- 导入soap协议的服务支持 serviceClass为对应的webService接口类-->
< jaxws:server id= "ResumeUpload" serviceClass= "com.sigmatrix.soap.webService.DemoService"
address= "/ResumeUpload" >
<!-- 添加webService接口实现类 -->
<jaxws:serviceBean >
<ref bean = "demoServiceImpl" />
</jaxws:serviceBean >
<!-- 添加协议 使用MTOM附件-->
<jaxws:properties >
<entry key = "mtom-enabled" value= "true" />
</jaxws:properties >
</jaxws:server >
</ beans>

4. 要开放的接口加上cxf服务的注解
接口类:
@WebService (portName = "inbound.webServices.ticket.saServiceSoap12" )
@javax.xml.ws.soap. MTOM
public interface DemoService {
@WebMethod
public String demo( @WebParam(name = "demo") Demo demo);
}
接口实现类:
@Component
@WebService (portName = "inbound.webServices.ticket.saServiceSoap12" )
@BindingType (value = "http://www.w3.org/2003/05/soap/bindings/HTTP/" )
public class DemoServiceImpl implements DemoService {
public String Demo(Demo demo) {
String userName = demo.getUserName();
String password= demo.getPassword();
return "success";
}
Demo实体类:
public Class Demo() {
public String userName;
public String password;

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password= password;
}
}
5. 部署到tomcat启动即可,测试访问 ip:端口号//项目名称/services/

通过CXF,开发soap协议接口的更多相关文章

  1. JMeter5.1开发Java协议接口脚本【待完成】

    JMeter5.1开发Java协议接口脚本

  2. 通过CXF,开发rest协议接口

    1. 引入cxf的jar包 pom文件里面直接增加依赖 < dependency> <groupId > junit</ groupId> <artifact ...

  3. WebService- 使用 CXF 开发 SOAP 服务

    选框架犹如选媳妇,选来选去,最后我还是选了“丑媳妇(CXF)”,为什么是它?因为 CXF 是 Apache 旗下的一款非常优秀的 WS 开源框架,具备轻量级的特性,而且能无缝整合到 Spring 中. ...

  4. (二)使用CXF开发WebService服务器端接口

    CXF作为java领域主流的WebService实现框架,Java程序员有必要掌握它. CXF主页:http://cxf.apache.org/ 简介:百度百科 今天的话,主要是用CXF来开发下Web ...

  5. cxf+spring+soap简单接口开发

    最近学了cxf框架开发webservice,简单搭了个接口,方便后续翻阅,本人才疏学浅,若有不足,请多多谅解! 一.服务端: 1.所用到的jar包: maven的pom.xml配置: <proj ...

  6. JMeter5.1开发TCP协议接口脚本

    最简单的方法,就是找开发给报文,直接复制到tcp取样器中,将需要变化的值做参数化就可以了.(xml报文要去掉回车换行) 下面是一个通讯头定义 通讯头56个字节(1个字符一个字节) 3 + 9 + 9 ...

  7. LoadRunner开发ftp协议接口之上传文件脚本

    Action() { //建立一个ftp对象 FTP ftp1=0; //建立FTP连接并登录 ftp_logon_ex(&ftp1,"ftpLogon", "U ...

  8. LoadRunner开发http协议接口之form表单脚本

    loadrunner传form表单,用web_submit_data函数. Action() { // lr_start_transaction("hp_homepage"); / ...

  9. JMeter5.1开发http协议接口之form表单脚本

    get请求--jmeter:form表单 下载文件 响应结果 post请求--jmeter:form表单 登录请求 响应结果 post请求--jmeter:form表单中传token 请求(token ...

随机推荐

  1. vuex到底是什么?

    vuex到底是什么? 使用vue也有一段时间了,但是对vue的理解似乎还是停留在初始状态,究其原因,不得不说是自己没有深入进去,理解本质,导致开发效率低,永远停留在表面, 更坏的结果就是refresh ...

  2. Linux du与df命令的差异

    今天上午查看磁盘空间,df命令查看的时候:93%,du命令查看的时候:90%.回想起昨天在用ftp传输过程中,rm掉文件,应该是文件虽然表明上删除掉了,但是空间实际是未释放的. 由于du与df命令实施 ...

  3. unittest实现批量处理测试集

    批量执行测试集 #coding=utf-8 from selenium import webdriver from selenium.webdriver.common.by import By fro ...

  4. 关于reduce的使用方法

    var rowData=[ {data:4,date:'06',code:'cr_3',name:'桥吊3'}, {data:1,date:'03',code:'cr_1',name:'桥吊1'}, ...

  5. 【Lua】遍历目录结果输出到页面中,刷新页面后出现500 Internal Server Error

    在通过lua获取目录json字符串,然后作为数据源,通过Extjs生成树的过程中,发生了一个奇怪的问题,那就是获取目录json字符串然后传递给Extjs生成树的这个过程中,一开始都是很顺利的就生成了, ...

  6. h5空白页面过渡加载

    h5空白页面过渡加载 页面第一部分内容是图片,考虑到手机图片加载慢,想用简单.转化为base64的图片过渡 开始尝试将图片转为灰度图片,结果还是很大. 后来选取重要元素,保存2位的png,尺寸是494 ...

  7. MySQL之函数

    了解编程的人一般都会知道函数的重要性,丰富的函数有的时候可以给我们带来事半功倍的效果,在MySQL中提供了许多的内置函数,能够帮助开发人员编写简单快捷的SQL语句,除了这些内置的函数之外,用户也可以自 ...

  8. 自动收缩数据库T-SQL

    alter database 数据库名 set auto_update_statistics off alter database 数据库名 set auto_update_statistics on

  9. 【转】.net MVC 生命周期

    对于Asp.net MVC,我对它的生命周期还是兴趣很浓,于是提出两个问题: 一个HTTP请求从IIS移交到Asp.net运行时,Asp.net MVC是在什么时机获得了控制权并对请求进行处理呢?处理 ...

  10. 在 Azure 上创建和链接 Azure SQL 数据库

    本快速入门介绍了如何在 Azure 门户中创建并连接 Azure SQL 数据库.在本教程中完成的所有操作均符合 1 元试用条件. 开始之前 如果您还没有 Azure 账户,可以申请 1 元试用账户. ...