浏览 2651 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-07-23
利用CXF发布Webservice没有问题,同样只是接受webservice服务也没有问题。但是我这里,只要把他们两个的xml文件配置同时放在web容器内,就报空指针异常,请哪位大哥指点一下: 1、client的配置文件: <?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:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" default-lazy-init="true" default-autowire="byName"> <jaxws:client xmlns:jaxws="http://cxf.apache.org/jaxws" id="commodityServiceClient" serviceClass="com.XXX.XXX" address="${webservice.client.host}/XXXervice"> <jaxws:binding> <soap:soapBinding xmlns:soap="http://cxf.apache.org/bindings/soap" mtomEnabled="true" version="1.2" /> </jaxws:binding> <jaxws:dataBinding> <bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding" /> </jaxws:dataBinding> </jaxws:client> </benas> 2. server的配置文件: <?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:simple="http://cxf.apache.org/simple" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" default-lazy-init="false" default-autowire="byName"> <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-extension-local.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:server xmlns:jaxws="http://cxf.apache.org/jaxws" id="configServiceWebServer" serviceBean="#XXXService" address="/XXXService"> <jaxws:serviceFactory> <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" scope="prototype"> <property name="dataBinding"> <bean id="xmlBean" class="org.apache.cxf.xmlbeans.XmlBeansDataBinding" scope="prototype" /> </property> </bean> </jaxws:serviceFactory> </jaxws:server> </beans> 3. 报出的异常是: java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoi ntInfo(AbstractWSDLBasedEndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoi nt(AbstractWSDLBasedEndpointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.ja va:51) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFact oryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBe an.java:93) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.beans.factory.support.SimpleInstantiationStrategy .instantiate(SimpleInstantiationStrategy.java:115) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-07-23
胡乱猜一下,是否和配置文件加载的顺序有关。正常来说应该先加载server的,并且 server 完全启动起来之后,再加载client的才可以,否则应该会有问题。
不明白你为什么把server/client同时部署到一个web容器里。 |
|
返回顶楼 | |
发表时间:2008-07-23
是有原因的: 它消费别人的webservice, 同时提供自己的webservice给别人,这样不是很正常吗?
|
|
返回顶楼 | |
发表时间:2008-07-23
补充一下:也就是说发布的webservice和消费的webservice不是同一个webservice。。。
|
|
返回顶楼 | |
发表时间:2008-07-24
问题已经解决, 问题的关键在于Web容器对多个spring xml配置文件的加载顺序,对于webservice的xml文件,由于其加载时间长,必须放在前面先行加载,这样后面的引用才可以。。。个人再多猜想一下:如果整合成一个大的xml文件,应该就没有这样的问题了。。
|
|
返回顶楼 | |