创建CXF Web服务客户端时出现ServiceConstructionException [英] ServiceConstructionException when creating a CXF web service client

查看:2045
本文介绍了创建CXF Web服务客户端时出现ServiceConstructionException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Web服务客户端,并且在创建Web服务时收到以下错误.我想知道我是否在此错误上丢失了一些东西:

I created a web service client and I am receiving the following error when the web service is being created. I was wondering if I am missing something on this error:

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);

推荐答案

似乎您在类路径上没有肥皂绑定.如果使用Maven,您是否将cxf-rt-bindings-soap工件作为依赖项?

It looks like you don't have the soap binding on the classpath. If using maven, do you have the cxf-rt-bindings-soap artifact as a dependency?

这篇关于创建CXF Web服务客户端时出现ServiceConstructionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆