webService cxf 客户端调用服务问题

用cxf写好服务端程序之后,在网页上输入http://xxxxxxxxxx?wsdl可以得到结构信息,服务端发布没有问题。然后我写客户端调用服务端程序,用的如下代码(动态代理 ):

     JaxWsDynamicClientFactory jfb =JaxWsDynamicClientFactory.newInstance();
     org.apache.cxf.endpoint.Client client = jfb.createClient("http://xxxxxx:port/ws/GetCarInfoHandler?wsdl");
    
        
        QName name = new  QName("http://xxxxxx:port/ws/GetCarInfoHandler","process");
        
        String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>....."

        try {
            Object[] objects = client.invoke(name, xmlStr);
            System.out.println(objects[0].toString());
        } catch (Exception e) {
            
            e.printStackTrace();
        }

然后报如下错误:

log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:86)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:295)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:240)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:233)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:188)
    at test.ClientTest.main(ClientTest.java:25)
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:264)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:84)
    ... 5 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:315)
    at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:265)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1774)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1673)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:254)
    ... 7 more

我在网上查了下好像说是 org.apache.cxf.endpoint.Client client = jfb.createClient("http://xxxxxx:port/ws/GetCarInfoHandler?wsdl");这一句代码追踪输入的url不对,可是我直接复制这个url到浏览器上可以打开的啊qvq 请问下各位大神是怎么回事。
(ps:我也试了用axis的方法去得到服务端信息,还是报错并强调wsdl路径是否正确)

阅读 9.4k
1 个回答
新手上路,请多包涵

你好 我这里也是这个错误,请问你的解决了吗

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进