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

时间:2010-06-09 16:27:08

标签: cxf

我从以下代码中收到以下错误[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);

我对网络服务的不熟悉继续让我感到悲伤。

[1]警告:{http://localhost:8080/gateway/services/SQLServiceSoap?wsdl} SQLServer的拦截器#{http://gateway.sf.net/sql} Ping抛出异常,现在解除 org.apache.cxf.interceptor.Fault:无法发送消息。         at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48)         at 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:地址无效。端点地址不能为空。         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)         在org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:496)         at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)

2 个答案:

答案 0 :(得分:2)

根本没有设置终点,如果它与您在WSDL中的不同,CXF不会为您配置终点。

答案 1 :(得分:0)

请 检查wsdl文件的路径