CXF 客户端 Web 服务 Ping 引发异常无法发送消息。地址无效。端点地址不能为空
我从以下代码中收到以下错误 [1]:
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("http://localhost:8080/gateway/services/SQLServiceSoap?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");
LOG.warn("PONG!: " + result);
我对 Web 服务的不熟悉继续让我感到悲伤。
[1]警告:拦截器 {http://localhost:8080/gateway/services/SQLServiceSoap? wsdl}SQLService#{http://gateway.sf.net/sql}Ping已引发异常,现在展开 org.apache.cxf.interceptor.Fault:无法发送消息。 在org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48) 在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) 在 org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:484) 在 org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310) 在 org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:262) 在 org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) 在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) 在 $Proxy37.ping(来源不明) 在net.sf.gateway.client.base.sql.SQLClientBase.setSecurityHeaderTokens(SQLClientBase.java:255) 在 net.sf.gateway.client.base.sql.SQLClientBase.get(SQLClientBase.java:289) 在net.sf.gateway.client.module.sql.SQLModule.getBatch(SQLModule.java:149) 在net.sf.gateway.client.module.sql.SQLModule.getAndProcessSQL(SQLModule.java:110) 在net.sf.gateway.client.module.sql.SQLModule.run(SQLModule.java:280) 在net.sf.gateway.client.GatewayClient.exec(GatewayClient.java:399) 在net.sf.gateway.client.GatewayClient.run(GatewayClient.java:174) 在 net.sf.gateway.client.GatewayClient.main(GatewayClient.java:166) 引起原因:java.net.MalformedURLException:地址无效。端点地址不能为空。 在 org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:833) 在 org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:815) 在 org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:741) 在 org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:496) 在 org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
I am getting the following error [1] from the following code:
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("http://localhost:8080/gateway/services/SQLServiceSoap?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");
LOG.warn("PONG!: " + result);
My unfamiliarity with webservices continues to cause me grief.
[1]WARNING: Interceptor for {http://localhost:8080/gateway/services/SQLServiceSoap?wsdl}SQLService#{http://gateway.sf.net/sql}Ping has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:484)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:262)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy37.ping(Unknown Source)
at net.sf.gateway.client.base.sql.SQLClientBase.setSecurityHeaderTokens(SQLClientBase.java:255)
at net.sf.gateway.client.base.sql.SQLClientBase.get(SQLClientBase.java:289)
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: java.net.MalformedURLException: Invalid address. Endpoint address cannot be null.
at org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:833)
at org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:815)
at org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:741)
at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:496)
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根本没有设置端点,如果端点与 WSDL 中的端点不同,CXF 不会为您配置端点。
End point was not setup at all, and CXF does not configure your End Point for you if it is different than what you have in your WSDL.