web-services – 创建CXF Web服务客户端时的ServiceConstructionException

前端之家收集整理的这篇文章主要介绍了web-services – 创建CXF Web服务客户端时的ServiceConstructionException前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个Web服务客户端,我在创建Web服务时收到以下错误.我想知道我是否遗漏了这个错误
Error running sql module: org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:298)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:291)
        at javax.xml.ws.Service.getPort(Service.java:44)
        at net.sf.gateway.client.base.sql.sqlClientBase.setSecurityHeaderTokens(sqlClientBase.java:244)
        at net.sf.gateway.client.base.sql.sqlClientBase.get(sqlClientBase.java:292)
        at net.sf.gateway.client.module.sql.sqlModule.getBatch(sqlModule.java:149)
        at net.sf.gateway.client.module.sql.sqlModule.getAndProcesssql(sqlModule.java:110)
        at net.sf.gateway.client.module.sql.sqlModule.run(sqlModule.java:280)
        at net.sf.gateway.client.GatewayClient.exec(GatewayClient.java:399)
        at net.sf.gateway.client.GatewayClient.run(GatewayClient.java:174)
        at net.sf.gateway.client.GatewayClient.main(GatewayClient.java:166)
Caused by: 
org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:404)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:258)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:146)
        at org.apache.cxf.frontend.Clientfactorybean.create(Clientfactorybean.java:51)
        at org.apache.cxf.frontend.ClientProxyfactorybean.create(ClientProxyfactorybean.java:102)
        at org.apache.cxf.jaxws.JaxWsProxyfactorybean.create(JaxWsProxyfactorybean.java:115)
        at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:437)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:296)
        ... 10 more
Caused by: 
org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered.
        at org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:91)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:394)
        ... 17 more

这是代码

ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL WSDL_LOCATION=null;
if ( null == cl ) cl = sqlService.class.getClassLoader();
WSDL_LOCATION = cl.getResource( "sqlServiceSoap.wsdl" );
QName SERVICE_NAME = new QName("https://myurl.org/services/myService?wsdl","sqlService");
Service service = Service.create(WSDL_LOCATION,SERVICE_NAME);
SOAPport sqlService = service.getPort(SOAPport.class);
Client client = org.apache.cxf.frontend.ClientProxy.getClient(sqlService);
Endpoint cxfEndpoint = client.getEndpoint();
Map<String,Object> outProps = new HashMap<String,Object>();
outProps.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER,soapUser);
outProps.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,PasswordCallbackHandler.class.getName());
outProps.put("password",soapPass);
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);

String result = sqlService.ping("test");

这就是它死的地方:SOAPport sqlService = service.getPort(SOAPport.class);

解决方法

看起来你没有类路径上的soap绑定.如果使用maven,您是否将cxf-rt-bindings-soap工件作为依赖项?

猜你在找的HTML相关文章