cxf的webservice部署

建一个web project,用了spring

需要发布的webservice接口为
import javax.jws.WebService;
@WebService
public interface BlackteaService


对应的实现类
@WebService(endpointInterface = "com.tc.blacktea.webservice.BlackteaService")
public class BlackteaServiceImpl implements BlackteaService


web.xml
   <context-param>			
  		<param-name>contextConfigLocation</param-name>
			<param-value>
				classpath:/applicationContext.xml
				classpath:spring-cxf.xml
			</param-value>
		</context-param>

    <servlet>  
        <servlet-name>CXFServlet</servlet-name>  
        <servlet-class>  
            org.apache.cxf.transport.servlet.CXFServlet   
        </servlet-class>  
        <load-on-startup>1</load-on-startup>  
    </servlet>   
    <servlet-mapping>  
        <servlet-name>CXFServlet</servlet-name>  
        <url-pattern>/ws/*</url-pattern>  
    </servlet-mapping>  


增加spring-cxf.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    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.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <import resource="classpath:META-INF/cxf/cxf.xml" />  
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
    <bean name="blackteaService" class="com.tc.blacktea.webservice.BlackteaServiceImpl"/>
    <jaxws:endpoint id="blackteaServiceWS" implementor="#blackteaService"  
        address="/BlackteaService" />  
  </beans>



jar包见附件
project结构见附件

访问http://localhost:8080/blackteaone/ws/BlackteaService?wsdl即可看到

猜你喜欢

转载自lvxing607.iteye.com/blog/1538494