使用cxf3.0.4搭建webservice服務須要的最精簡jar包

  轉自:https://blog.csdn.net/w1014074794/article/details/47862163html

下面是測試結果,只列出報錯了的測試:java

一、org.apache.catalina.LifecycleException: A child container failed during start
缺乏:cxf-core-3.0.4.jar(最核心的包,很少說)


二、java.lang.ClassNotFoundException: org.apache.cxf.binding.soap.SoapBindingConfiguration
缺乏:cxf-rt-bindings-soap-3.0.4.jar       (soap協議)

web

三、org.apache.cxf.jaxb.JAXBDataBinding:
缺乏:cxf-rt-databinding-jaxb-3.0.4.jar      


四、加載Application文件時出現Unable to locate Spring NamespaceHandler for XML schema namespace
     [http://cxf.apache.org/jaxws]spring

缺乏:cxf-rt-frontend-jaxws-3.0.4.jar    (frontend 前置的意思,你懂的)

五、org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser錯誤:
缺乏:cxf-rt-frontend-simple-3.0.4.jar


六、class path resource [META-INF/cxf/cxf-servlet.xml] cannot be opened because it does not exist
缺乏:cxf-rt-transports-http-3.0.4.jar


七、org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://cxf.apache.org/transports/udp.
缺乏:cxf-rt-transports-udp-3.0.4.jarapache


八、org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl startup
警告: Could not start WS-Discovery Service.
javax.xml.ws.WebServiceException: java.lang.NullPointerException
不能初始化配置的bean服務,也就是運行到<jaxws:server>時出錯

缺乏:cxf-rt-ws-addr-3.0.4.jar

九、java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.AssertionInfoMap
缺乏:cxf-rt-ws-policy-3.0.4.jar        


十、java.lang.ClassNotFoundException: org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
缺乏:cxf-rt-wsdl-3.0.4.jar

十一、java.lang.ClassNotFoundException: org.apache.neethi.AssertionBuilderFactory
缺乏:neethi-3.0.3.jar

十二、java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
缺乏:slf4j-api-1.7.9.jar

1三、java.lang.ClassNotFoundException: org.apache.ws.commons.schema.resolver.URIResolver
缺乏:xmlschema-core-2.2.1.jarapi

 

因此,總結cxf3.0.4框架必需的包爲:
cxf-core-3.0.4.jar
cxf-rt-bindings-soap-3.0.4.jar
cxf-rt-databinding-jaxb-3.0.4.jar
cxf-rt-frontend-jaxws-3.0.4.jar
cxf-rt-frontend-simple-3.0.4.jar
cxf-rt-transports-http-3.0.4.jar
cxf-rt-transports-udp-3.0.4.jar
cxf-rt-ws-addr-3.0.4.jar
cxf-rt-wsdl-3.0.4.jar
cxf-rt-ws-policy-3.0.4.jar
cxf-rt-wsdl-3.0.4.jar
neethi-3.0.3.jar
slf4j-api-1.7.9.jar
xmlschema-core-2.2.1.jarapp

注意:這裏不包括spring依賴包和commoms下的jar包框架

 

引入CXF Bean定義以下,早期的版本中使用,若是是servlet引入的話則下面三句不用了,由於框架引入了 
配置文件中不須要:
 <import resource="classpath:META-INF/cxf/cxf.xml"/>
 <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
 <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />frontend

 

[html]  view plain  copy
 
  1. <!-- scope="singleton"單例 -->  
  2.   <bean id="userServiceBean" class="com.winit.webservice.UserWebService">  
  3.   </bean>  
  4.    <!-- 注意下面的address,這裏的address的名稱就是訪問的WebService的name -->   
  5.    <jaxws:server id="userService" serviceClass="com.winit.webservice.IUserWebService" address="/Users">      
  6.     <jaxws:serviceBean>           
  7.         <!-- 要暴露的 bean 的引用 -->          
  8.         <ref bean="userServiceBean"/>       
  9.     </jaxws:serviceBean>       
  10.   </jaxws:server>  


web.xml中添加cxf的servlet測試

 

 

[html]  view plain  copy
 
  1. <servlet>    
  2.     <servlet-name>CXFService</servlet-name>    
  3.     <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>    
  4. </servlet>            
  5. <servlet-mapping>    
  6.     <servlet-name>CXFService</servlet-name>    
  7.     <url-pattern>/webservice/*</url-pattern>    
  8. </servlet-mapping>   

 

 

項目名是WebAdvanced,服務啓動後,訪問連接:http://localhost:8080/WebAdvanced/webservice/Users?wsdl。說明發布的webservice服務成功。

相關文章
相關標籤/搜索