cxf2.7.15-作为webService客户端遇到的问题

1、Exception in thread "main" java.lang.NoSuchFieldError: QUALIFIED

    at org.apache.cxf.service.model.SchemaInfo.setSchema(SchemaInfo.java:146)

    at org.apache.cxf.wsdl11.SchemaUtil.extractSchema(SchemaUtil.java:143)

    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:73)

    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:65)

    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:60)

    at org.apache.cxf.wsdl11.WSDLServiceBuilder.getSchemas(WSDLServiceBuilder.java:372)

    at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:339)

    at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:196)

    at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:172)

    at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:125)

    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:298)

    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 com.ruijie.test.WebServiceTest.testService(WebServiceTest.java:170)

    at com.ruijie.test.WebServiceTest.main(WebServiceTest.java:66)

以上的异常是由于采用的jar包与cxf版本不匹配导致的。原来使用的是XmlSchema-1.4.7.jar,将其删除修改为:xmlschema-core-2.1.0.jar

 

 

2、Exception in thread "main" java.lang.NoSuchMethodError: org.apache.ws.security.util.WSSecurityUtil.decodeAction(Ljava/lang/String;Ljava/util/List;Lorg/apache/ws/security/WSSConfig;)I

    at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:200)

    at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:141)

    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)

    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:572)

    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:481)

    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)

    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)

    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)

    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:341)

    at com.ruijie.test.WebServiceTest.testService(WebServiceTest.java:190)

    at com.ruijie.test.WebServiceTest.main(WebServiceTest.java:65)

以上的原因是由于(CXF 2.3.3 needs WSS4J 1.5.x. CXF 2.4.x uses WSS4J 1.6.x.(转)),cxf2.7.15使用的wss4j应该是用从Apache网站下载下来的压缩包里面的版本。

 客户端依赖的jar包,如下:技术分享

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。