我将 CXF 用于我的 Web 服务后端/客户端存根。当客户端调用 Web 服务时,我收到以下错误:
java.lang.NullPointerException
at org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:559)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:497)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:442)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:680)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:505)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:242)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:144)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:133)
at com.amazonws.AmazonWS.createAmazonWS(AmazonWS.java:49)
第 49 行指向以下指令:
AmazonWS client = (AmazonWS) factory.create();
在以下块之后:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(AmazonWS.class);
factory.setAddress("http://localhost:9000/helloAmazon");
我究竟做错了什么 ?看来我的客户甚至无法访问网络服务。为什么 ?
谢谢