CXF中使用dataBinding时遇到异常的解决办法

      不罗嗦,直接问题描述:我在使用java优先的方式写CXF服务时,因为用到了Map类型,所以想到使用CXF框架非默认的Aegis数据绑定方式。但是按照我自以为的方式配置的bean文件,在发布时遇到了异常:

异常摘要
nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'dataBinding' of bean class [org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl]: Bean property 'dataBinding' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
 

我原来的配置文件为:

<?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"
	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">

	<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" />

	
	<jaxws:endpoint id="LabsQuerying" implementor="rc.yuzone.services.LabsQueryImpl"
		address="/LabsQueryingService">
		<jaxws:dataBinding>
			<bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
		</jaxws:dataBinding>
	</jaxws:endpoint>

</beans>
 

      后来谷歌了好久,终于在一张已经被删了的网页中(还好有快照功能)找到了灵感,我修改了配置文件,用了另一种绑定方式:

<?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"
	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">

	<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" />

	
	<jaxws:endpoint id="LabsQuerying" implementor="rc.yuzone.services.LabsQueryImpl"
		address="/LabsQueryingService">
		<jaxws:serviceFactory>
			<bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
				<property name="dataBinding" ref="aegisBean" />
				<property name="serviceConfigurations">
					<list>
						<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration" />
						<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration" />
						<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration" />
					</list>
				</property>
			</bean>
		</jaxws:serviceFactory>
	</jaxws:endpoint>
	<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>

</beans>
 

    如此修改以后再部署,Spring就不报错了,至少可以部署成功了。至于是否影响后续的开发,还有待时间检验;至于为什么,再研究吧。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值