配置 cxf-rs spring bean 文件
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/docs/restful-services.html
示例:
<?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:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
">
<import resource="classpath:META-INF/cxf/cxf.xml" /> <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" />
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> <cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus> <jaxrs:server id="services" address="/">
<jaxrs:serviceBeans>
<bean class="cn.zno.HelloWorld" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider" />
<ref bean="jaxbProvider" />
</jaxrs:providers>
<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:server>
</beans>
没有endpoint
<xsd:element name="server">...</xsd:element>
<xsd:element name="client">...</xsd:element>
jaxrs:server
<xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
<xsd:attribute name="address" type="xsd:string"/>
<xsd:attribute name="bus" type="xsd:string"/>
<xsd:attribute name="serviceClass" type="xsd:string"/>
<xsd:attribute name="transportId" type="xsd:string"/>
<xsd:attribute name="modelRef" type="xsd:string"/>
<xsd:attribute name="bindingId" type="xsd:string"/>
<xsd:attribute name="staticSubresourceResolution" type="xsd:boolean"/>
<xsd:attribute name="beanNames" type="xsd:string"/>
<xsd:attribute name="serviceName" type="xsd:QName"/>
<xsd:attribute name="docLocation" type="xsd:string"/>
<xsd:attribute name="publishedEndpointUrl" type="xsd:string"/>
<xsd:attribute name="basePackages" type="xsd:string"/>
<xsd:attribute name="serviceAnnotation" type="xsd:string"/>
<xsd:attribute name="publish" type="xsd:boolean"/>
<xsd:all>
<xsd:element name="executor" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="features" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="binding" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="dataBinding" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="invoker" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="serviceFactories" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="properties" type="beans:mapType" minOccurs="0"/>
<xsd:element name="serviceBeans" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="modelBeans" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="model" type="model" minOccurs="0"/>
<xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="extensionMappings" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="languageMappings" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="schemaLocations" type="schemasType" minOccurs="0"/>
<xsd:element name="resourceComparator" type="xsd:anyType" minOccurs="0"/>
</xsd:all>
开启日志
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus> 增加后,请求时,增加如下日志:
七月 , :: 下午 org.apache.cxf.interceptor.LoggingInInterceptor
信息: Inbound Message
----------------------------
ID:
Address: http://localhost:8080/cxf-jaxrs-service/hello/jsonBean
Encoding: ISO--
Http-Method: POST
Content-Type: application/json
Headers: {Accept=[application/json], cache-control=[no-cache], connection=[keep-alive], Content-Length=[], content-type=[application/json], host=[localhost:], pragma=[no-cache], user-agent=[Apache CXF 3.1.]}
Payload: {"val2":null,"val1":"Maple"}
--------------------------------------
七月 , :: 下午 org.apache.cxf.interceptor.LoggingOutInterceptor
信息: Outbound Message
---------------------------
ID:
Response-Code:
Content-Type: application/json
Headers: {Content-Type=[application/json], Date=[Thu, Jul :: GMT]}
Payload: {"val2":"Maple","val1":"Maple"}
--------------------------------------
效果等同于:
<bean id="inInterceptors" class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
<bean id="outInterceptors" class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
[...]
<jaxrs:inInterceptors>
<ref bean="inInterceptors" />
</jaxrs:inInterceptors>
<jaxrs:outInterceptors>
<ref bean="outInterceptors" />
</jaxrs:outInterceptors>
权限验证
http://cxf.apache.org/docs/security.html
配置 cxf-rs spring bean 文件的更多相关文章
- 配置 cxf-ws spring bean 文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Spring Bean几种注入方式——setter(常用),构造器,注入内部Bean,注入集合,接口...
依赖注入分为三种方式: 1.1构造器注入 构造器通过构造方法实现,构造方法有无参数都可以.在大部分情况下我们都是通过类的构造器来创建对象,Spring也可以采用反射机制通过构造器完成注入,这就是构造器 ...
- 【Spring】IoC容器 - Spring Bean作用域Scope(含SpringCloud中的RefreshScope )
前言 上一章学习了[依赖来源],本章主要讨论SpringBean的作用域,我们这里讨论的Bean的作用域,很大程度都是默认只讨论依赖来源为[Spring BeanDefinition]的作用域,因为在 ...
- Spring配置bean文件的底层实现方式
首先 bean文件如下: <beans> <bean id="date" class="java.util.Date"></bea ...
- Spring基础——在Spring Config 文件中配置 Bean
一.基于 XML 的 Bean 的配置——通过全类名(反射) <bean <!-- id: bean 的名称在IOC容器内必须是唯一的若没有指定,则自动的将全限定类名作为 改 bean 的 ...
- Spring bean工厂配置头文件
命名 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...
- CXF和spring整合遇到的问题:No bean named 'cxf' is defined
今天在做ws和spring整合的时候,很不幸的遇到了这个问题,百度了好久,竟然没人遇到这个问题,后来谷歌了一下,都是遇到这个问题的了...在看到一篇文章中提到了cxf.xml,所以我果断的打开这个配置 ...
- webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成
首先到CXF官网及spring官网下载相关jar架包,这个不多说.webservice是干嘛用的也不多说. 入门例子 模拟新增一个用户,并返回新增结果,成功还是失败. 大概的目录如上,很简单. Res ...
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
随机推荐
- php, postgresql 安装
sudo yum install postgresql84-server postgresql84-contrib ubuntu下面安装的问题解决: Postgresql installation o ...
- 一个完整的Oracle建表的例子
建表一般来说是个挺简单的事情,但是Oracle的建表语句有很多可选的参数,有些我们可能平时不太用,用的时候又不知道怎么用,这里就写一个较完整的建表的例子: [sql] CREATE TABLE ban ...
- tensorflow学习资料
tensorflow学习资料 http://www.soku.com/search_video/q_tensorflow?f=1&kb=04112020yv41000__&_rp=1a ...
- python闭包和装饰器(转)
一.python闭包 1.内嵌函数 >>> def func1(): ... print ('func1 running...') ... def func2(): ... prin ...
- MySQL8 重置改root密码及开放远程访问
1. 修改配置文件 先修改配置文件:vim /etc/my.conf 在 [mysqld] 下加上下面这行 skip-grant-tables 重启 mysql 服务: service mysqld ...
- for循环计算阶乘
int x = 10; for(int y = x - 1; y >= 1; y--) { x = x * y; } System.out.println(x); 从10乘到1的阶乘写法. lo ...
- java.lang.IllegalArgumentException: Service not registered
java.lang.IllegalArgumentException: Service not registered 首先检查一下,Service是否在AndroidManifest文件中注册.格式如 ...
- 使用git提交代码到GitHub
0.下载Git Bash,在Windows系统可以用Git Bash通过简单的命令将代码提交到GitHub1.打开项目所在的文件夹,右键,"Git Bash Here"2.初次使用 ...
- linux、centos下查看系统版本、bios版本,内存信息等
1.查看系统版本 [root@localhost ~]# more /etc/issueCentOS release 6.2 (Final)Kernel \r on an \m 2.查看CPU信息 : ...
- Ubuntu 16.04安装Git及GUI客户端
1.通过APT源安装Git命令行工具 这里不建议通过源码进行安装,增加复杂程度,且最新版本的Git在各个方面都会修复,不至于出现不能用的状态. sudo add-apt-repository ppa: ...