日期:2014-05-16  浏览次数:20896 次

CXF + spring 的org.apache.cxf.frontend.WSDLQueryException:

之前用jax-ws写了一个webservice,但是和现有SSH的一个应用系统结合后,没法获取spring的application.xml里的sessionFactory配置。只能在WS的构造体里写

// String fs = new File(HyDataWrapperWS.class.getResource("/").getPath()).getParent()+"/webservice.xml";

// Resource rs = new FileSystemResource(fs);?

// BeanFactory factory = new XmlBeanFactory(rs);?

//

// HyDataWrapperWSProcess p = (HyDataWrapperWSProcess)factory.getBean("hydatawrapperwsprocess");

手动的获取bean。并且webservice.xml还得重复一遍定义datasource和sessionfactory。
后来打算用cxf来重新构造webservice,就是看到cxf和spring可以完美结合。
按照apache的标准教程一步一步下来,
http://localhost:8080/hy/service//HyDataWrapperWSService?wsdl但是最后就是没法看到wsdl。
has thrown
> exception, unwinding now
>                                  org.apache.cxf.frontend.WSDLQueryException:
> Exception occurred while trying to process
> http://localhost:9081/MortgageGateway/soap/LnSetupLoanService
> 	at 
org.apache.cxf.frontend.WSDLGetUtils.getDocument(WSDLGetUtils.java:248)
> 	at
> org.apache.cxf.frontend.WSDLGetInterceptor.getDocument(WSDLGetInterceptor.ja
> va:158) at
> org.apache.cxf.frontend.WSDLGetInterceptor.handleMessage(WSDLGetInterceptor.
> java:110) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain
> .java:263) at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationOb
> server.java:123) at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDes
> tination.java:207) at
类似的错误。

找了很久,发现原来用jax-ws的时候引用了一个javax.wsdl_1.5.1.v200806030408.jar
现在cxf却有一个wsdl4j-1.6.2.jar包。里面的方法几乎一样。果断把javax.wsdl_1.5.1那个jar删除。一切问题解决。
还是一句老话,java工程里引用的jar包还是千万要注意版本冲突问题。