通过CXF,开发soap协议接口
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协议接口的更多相关文章
- JMeter5.1开发Java协议接口脚本【待完成】
JMeter5.1开发Java协议接口脚本
- 通过CXF,开发rest协议接口
1. 引入cxf的jar包 pom文件里面直接增加依赖 < dependency> <groupId > junit</ groupId> <artifact ...
- WebService- 使用 CXF 开发 SOAP 服务
选框架犹如选媳妇,选来选去,最后我还是选了“丑媳妇(CXF)”,为什么是它?因为 CXF 是 Apache 旗下的一款非常优秀的 WS 开源框架,具备轻量级的特性,而且能无缝整合到 Spring 中. ...
- (二)使用CXF开发WebService服务器端接口
CXF作为java领域主流的WebService实现框架,Java程序员有必要掌握它. CXF主页:http://cxf.apache.org/ 简介:百度百科 今天的话,主要是用CXF来开发下Web ...
- cxf+spring+soap简单接口开发
最近学了cxf框架开发webservice,简单搭了个接口,方便后续翻阅,本人才疏学浅,若有不足,请多多谅解! 一.服务端: 1.所用到的jar包: maven的pom.xml配置: <proj ...
- JMeter5.1开发TCP协议接口脚本
最简单的方法,就是找开发给报文,直接复制到tcp取样器中,将需要变化的值做参数化就可以了.(xml报文要去掉回车换行) 下面是一个通讯头定义 通讯头56个字节(1个字符一个字节) 3 + 9 + 9 ...
- LoadRunner开发ftp协议接口之上传文件脚本
Action() { //建立一个ftp对象 FTP ftp1=0; //建立FTP连接并登录 ftp_logon_ex(&ftp1,"ftpLogon", "U ...
- LoadRunner开发http协议接口之form表单脚本
loadrunner传form表单,用web_submit_data函数. Action() { // lr_start_transaction("hp_homepage"); / ...
- JMeter5.1开发http协议接口之form表单脚本
get请求--jmeter:form表单 下载文件 响应结果 post请求--jmeter:form表单 登录请求 响应结果 post请求--jmeter:form表单中传token 请求(token ...
随机推荐
- 生产html测试报告
批量执行完用例后,生成的测试报告是文本形式的,不够直观,为了更好的展示测试报告,最好是生成 HTML 格式的.unittest 里面是不能生成 html 格式报告的,需要导入一个第三方的模块:HTML ...
- ios 得到每周的星期一开始和星期天结束的日期
得到每周 星期一零点(即本周的开始) 和星期天 24 点(即本周的结束和下一周的开始)的时间 NSDate *now = [NSDate date]; NSCalendar *calendar = [ ...
- php的stristr()函数,查找字符
1.用法,要传2个参数 stristr(string,search):查找并返还匹配后,剩下的部分字符串 查找过程不区分大小写,要区分大小写用 strstr(string,search)少一个字母i ...
- 100行代码搞定抖音短视频App,终于可以和美女合唱了。
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由视频咖 发表于云+社区专栏 本文作者,shengcui,腾讯云高级开发工程师,负责移动客户端开发 最近抖音最近又带了一波合唱的节奏,老 ...
- weblogic JDBC Connection Pools--转官方文档
http://docs.oracle.com/cd/E13222_01/wls/docs81/ConsoleHelp/jdbc_connection_pools.html#1106016 JDBC C ...
- C#操作Redis String字符串
/// <summary> /// Redis String 操作 /// </summary> public static void Redis_String() { Red ...
- [转]使用依赖关系注入在 ASP.NET Core 中编写干净代码
本文转自:http://blog.jobbole.com/101270/ 原文出处: Steve Smith ASP.NET Core 1.0 是 ASP.NET 的完全重新编写,这个新框架的主 ...
- Query performance optimization of Vertica
Don't fetch any data that you don't need,or don't fetch any columns that you don't need. Because ret ...
- Full postback triggered by LinkButton inside GridView inside UpdatePanel
GridView inside of a UpdatePanel,get the button to trigger a partial postback <asp:ScriptManager ...
- How WindowLeaked exception occured?
If a Activity performDestroy, and there is window not closed whose window token is the Activity's mW ...