CXF與Web項目集成---without Spring

1.CXF集成web項目,是經過org.apache.cxf.transport.servlet.CXFNonSpringServlet進行集成 javascript

 

2.servlet java

 

Java代碼    收藏代碼
  1. public class WSServlet extends CXFNonSpringServlet {  
  2.   
  3.     /** 
  4.      *  
  5.      */  
  6.     private static final long serialVersionUID = 1L;  
  7.   
  8.     @SuppressWarnings("static-access")  
  9.     @Override  
  10.     public void loadBus(ServletConfig servletConfig) throws ServletException {  
  11.         super.loadBus(servletConfig);  
  12.           
  13.           
  14.         Endpoint.publish("/helloWorld"new HelloImpl())  
  15.                 .publish("/cal"new CalculatorImpl())  
  16.                 .publish("/userService"new UserServiceImpl());  
  17.                   
  18.     }  
  19. }  

 

經過Endpoint.publish發佈,咱們webService全部服務都在此發佈 web

 

 

3.配置咱們servlet apache

 

Xml代碼    收藏代碼
  1. <servlet>  
  2.     <servlet-name>WebServiceServlet</servlet-name>  
  3.     <servlet-class>com.cxf.servlet.WSServlet</servlet-class>  
  4. </servlet>  
  5.   
  6. <servlet-mapping>  
  7.     <servlet-name>WebServiceServlet</servlet-name>  
  8.     <url-pattern>/ws/*</url-pattern>  
  9. </servlet-mapping>  

 

  <url-pattern>/ws/*</url-pattern>不要配置成<url-pattern>/*</url-pattern>,不然你訪問那個頁面都會跳到 app

  websevice 服務列表的頁面,你想也頁面也就沒法到達了 ide

 

  訪問咱們wsdl地址,例如咱們本機http://localhost:8080/02_cxf/ws/userService?wsdl url

 


 這樣就能夠了,配置完,你能夠試着訪問你的wsdl。很簡單吧! spa

相關文章
相關標籤/搜索