CXF 客户端 Web 服务 Ping 引发异常无法发送消息。地址无效。端点地址不能为空

发布于 2024-09-04 18:32:03 字数 3391 浏览 1 评论 0原文

我从以下代码中收到以下错误 [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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦慕雪 2024-09-11 18:32:03

根本没有设置端点,如果端点与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文