在springmvc项目中使用webservice

1、引入maven依赖


 
org.apache.cxf
cxf-rt-frontend-jaxws
${cxf.version}


org.apache.cxf
cxf-rt-transports-http
${cxf.version}


2、创建webservice接口

  1. @WebService  
  2. public interface IHelloWorld {   
  3.     public String sayHello(String username);    
  4.     public void setUser(String username);   
  5. }  
3、创建实现类

  1. public class HelloWorldImpl implements IHelloWorld {  
  2.     @Override  
  3.     public String sayHello(String username) {  
  4.            
  5.         return "Hello " + username;  
  6.     }  
  7.   
  8.     @Override   
  9.     public void setUser(String username) {  
  10.            
  11.     }  
4、 在Web.xml中声明CXF监听器


CXFServlet
org.apache.cxf.transport.servlet.CXFServlet
1


CXFServlet
/webservice/*

5、创建spring-webservice-cxf.xml文件

 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd"> 


 
 


 
                                                   
 

你可能感兴趣的:(在springmvc项目中使用webservice)