(1)jar最小依赖
参考:http://gary0416.iteye.com/blog/1222915
部署到tomcat,项目启动后可以看到
经试验,不行,可能由于我用的是cxf3.0版本,还是全部jar吧!
(2)@XmlRootElement(name = "FlowInfo") 注解效果
使用前:
使用后:
(3)jsr331-api-1.1.1.jar是必须的,利用CXF发布REST服务得用到它。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
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://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
applicationXML.xml文件中加入如上链接,还是不行,报错:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'jaxrs:extensionMappings'. One of '{"http://cxf.apache.org/jaxws":binding, "http://
cxf.apache.org/jaxws":dataBinding, "http://cxf.apache.org/jaxws":executor, "http://cxf.apache.org/jaxws":features, "http://cxf.apache.org/jaxws":handlers, "http://
cxf.apache.org/jaxws":inInterceptors, "http://cxf.apache.org/jaxws":inFaultInterceptors, "http://cxf.apache.org/jaxws":invoker, "http://cxf.apache.org/
jaxws":outInterceptors, "http://cxf.apache.org/jaxws":outFaultInterceptors, "http://cxf.apache.org/jaxws":properties, "http://cxf.apache.org/jaxws":schemaLocations,
"http://cxf.apache.org/jaxws":serviceFactory}' is expected.
参考:http://blog.csdn.net/czp11210/article/details/8874321
(3)JAXB
JAXB可以相当灵活以支持其他格式,而不仅限于xml格式。
Jettison就是一个开源的JAXB适配器
参考:http://liugang594.iteye.com/blog/1499813
<FlowInfo settleFlowNo="0001">
<regOrg>zhongdeng</regOrg>
</FlowInfo>
(4)cxf把异常信息转换为JSON或者XML格式
参考:http://yufenfei.iteye.com/blog/1717098
第一步:编写自己的异常处理类 InvokeFaultExceptionMapper
@Provider
public class InvokeFaultExceptionMapper implements ExceptionMapper {
public Response toResponse(Throwable ex) {
StackTraceElement[] trace = new StackTraceElement[1];
trace[0] = ex.getStackTrace()[0];
ex.setStackTrace(trace);
ResponseBuilder rb = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
rb.type("application/json;charset=UTF-8");
rb.entity(ex);
rb.language(Locale.SIMPLIFIED_CHINESE);
Response r = rb.build();
return r;
}
}
第二部:加载InvokeFaultExceptionMapper
<jaxrs:server id="expGateway" address="/expGateway">
<jaxrs:inInterceptors>
<ref bean="inMessageInterceptor"/>
</jaxrs:inInterceptors>
<jaxrs:outInterceptors>
<ref bean="outMessageInterceptor"/>
</jaxrs:outInterceptors>
<jaxrs:serviceBeans>
<ref bean="expGatewayImpl" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
<jaxrs:languageMappings>
<entry key="en" value="en-gb" />
</jaxrs:languageMappings>
<jaxrs:providers>
<bean class="com.pml.service.outer.InvokeFaultExceptionMapper"/>
</jaxrs:providers>
</jaxrs:server>
(5)创建一个基于WS-Security标准的安全验证(CXF回调函数使用,)
参考:http://jyao.iteye.com/blog/1346547
相关推荐
第一天: 什么是webservice? 从案例(便民查询网站)分析如何实现?...CXF开发webservice: CXF入门程序 Spring+cxf整合(重点) CXF发布rest的webservice。(重点) 综合案例: 实现便民查询网站
SpringBoot+Mybatis+CXF框架,实现Restful api与 WebService api接口的大实验
CXF Webservice 开发手册
02.CXF功能概述_CXF发展历史和使用CXF开发WebService服务器端
cxf+spring+jdk1.5开发webService部署weblogic9.2
cxf 开发webservice客户端 代码经过测试
CXF实现简单的WebService接口开发,参考博客可以很好的理解并掌握
使用cxf和spring开发基于https的webservice服务端以及客户端样例
CXF开发webservice服务端,希望对大家有所帮助
CXF2+Spring2.5开发WebService实例,需要导入jar包
java通过cxf实现webservice所需jar包。java通过cxf实现webservice所需jar包。
Spring+CXF+tomcat开发webservice,包含服务端和客户端,导入myeclipse就可以用。帮助大家搭建webservice框架,实现webservice功能。
本java工程实现了spring+cxf快速开发webservice jar包齐全导入myeclipse可直接二次开发
cxf+spring+tomat开发webservice所需jar包,该jar包只需解压后导入web工程即可,亲测有用
WebService CXF 详细教程 加上自带CXF文件
Apache CXF是一个开源的Service框架,它实现了JCP与Web Service中一些重要标准。CXF简化了构造,集成,面向服务架构(SOA)业务组件与技术的灵活复用。在CXF中,Service使用WSDL标准定义并能够使用各种不同的消息格式...
借鉴网上例子,弄了一个SpringBoot开发WebService之CXF示例。
2.用cxf开发webservice 3.这个服务端和客户端的小demo 在服务端 对外开放接口服务,然后在客户端 调用服务端的方法, 实现客户端(一个javaweb项目)对服务端(javaweb项目)方法的调用, 实际上就是发送和接收消息...
cxf 方式下的webservice服务端开发的源码myeclipse源码,在http://www.oschina.net/里搜索cxf 方式下的webservice服务端开发的第一篇博客即是说明文档。
apache-cxf-2.4.6.zip