建一個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便可看到