CXF中使用dataBinding时遇到异常的解决办法
????? 不罗嗦,直接问题描述:我在使用java优先的方式写CXF服务时,因为用到了Map类型,所以想到使用CXF框架非默认的Aegis数据绑定方式。但是按照我自以为的方式配置的bean文件,在发布时遇到了异常:
<?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.xsdhttp://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 /></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.xsdhttp://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 ref="aegisBean" /><property name="serviceConfigurations"><list><bean /><bean /><bean /></list></property></bean></jaxws:serviceFactory></jaxws:endpoint><bean id="aegisBean" name="code"><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:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsdhttp://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!-- comment this bean to disable schema validation in the client --> <jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort" createdFromAPI="true"> <jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties> <jaxws:dataBinding> <bean value="true" /> </jaxws:properties> <jaxws:dataBinding> <bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/> </jaxws:dataBinding> </jaxws:endpoint></beans> 2 楼 jnn 2009-05-12 至于原理, 我的blog 里面有一些关于CXF configuration的介绍http://jnn.iteye.com/blog/120186