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. ant.design初探

    第一部分: 前言 推荐网站: https://ant.design/docs/spec/introduce-cn ant.design是基于react开发的一个解放ui和前端的工具,它提供了一致的设计 ...

  2. Java学习之路(二):流程控制语句

    Java流程控制语句 java的流程控制语句: 默认,顺序执行 if...else...条件控制语句 switch 选择语句 for循环 while循环 do...while循环 break,cont ...

  3. IE的haslayout的触发

    原文连接:http://www.cnblogs.com/yunxuange/archive/2012/09/19/2693886.html layout是Windows上的IE浏览器产生许多bug的根 ...

  4. C#操作Redis Set 无序集合

    /// <summary> /// redis 无序集合 /// </summary> public static void Redis_Set() { RedisClient ...

  5. Lucene学习之四:Lucene的索引文件格式(3)

    本文转载自:http://www.cnblogs.com/forfuture1978/archive/2010/02/02/1661436.html ,略有删改和备注. 四.具体格式 4.2. 反向信 ...

  6. Java - 网络IO的阻塞

    最近学习时碰到事件驱动和非阻塞的相关知识,随之想到了Java中的Reactor.io与nio的一些东西:在前辈的博客上翻了翻.复习复习,在此记录一番. 实在找不到比较大点的东西,于是随便弄了个压缩包, ...

  7. nodejs图片裁剪、缩放、水印

    关于nodejs下图片的裁剪.水印,网上的模块很多,主要如下: gm:https://github.com/aheckmann/gm node-canvas:https://github.com/Au ...

  8. Tomcat服务器使用(一)

    1. Tomcat服务器端口的配置 Tomcat服务器的配置文件主要在conf文件夹中,conf文件夹下的server.xml是配置文件的核心,默认的配置端口是8080,如果想要修改为其他的端口,可在 ...

  9. Cardinality Estimation算法学习(一)(了解基数计算的基本概念及回顾求字符串中不重复元素的个数的问题)

    最近在菜鸟教程上自学redis.看到Redis HyperLogLog的时候,对“基数”以及其它一些没接触过(或者是忘了)的东西产生了好奇. 于是就去搜了“HyperLogLog”,从而引出了Card ...

  10. Microsoft Windows Scripting Self-Paced Learning Guide

    http://www.mums.ac.ir/shares/hit/eduhit/book/windowsscripting.pdfhttp://support.microsoft.com/kb/926 ...