如果報了:
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean提示類找不到。點擊這里→即可解決
服務端可以正常運行,使用url調用也可以正常運行
今天在使用webservice的時候,訪問客戶端訪問服務端報了如下的錯:
Exception in thread "main" java.lang.AbstractMethodError: org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory.createConduit(Lorg/apache/cxf/transport/http/HTTPTransportFactory;Lorg/apache/cxf/Bus;Lorg/apache/cxf/service/model/EndpointInfo;Lorg/apache/cxf/ws/addressing/EndpointReferenceType;)Lorg/apache/cxf/transport/http/HTTPConduit; at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:233) at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:226) at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:233) at org.apache.cxf.endpoint.AbstractConduitSelector.createConduit(AbstractConduitSelector.java:144) at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:108) at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:882) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:526) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140) at com.sun.proxy.$Proxy37.sayHello(Unknown Source) at com.tao.service.Client.main(Client.java:29)
最后通過更改我們的CXF版本解決了這個問題:,發現是我的這個 cxf pom依賴與cxf-jaxws版本不一致導致的
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle</artifactId> <version>2.7.18</version> </dependency>
一同奉上
<!-- 要進行jaxws 服務開發 -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.18</version>
</dependency>
<!--內置jetty web服務器 cxf‐rt‐transports‐http‐jetty-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.7.18</version>
</dependency>