1)web.xml:
<servlet><servlet-name>CXFServlet</servlet-name>
<servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- 所有来自/webservice/*的请求交给cxf处理 -->
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>
2)jar包:
1、cxf-2.7.3
2、httpasyncclient-4.0-beta3.jar
3、httpclient-4.2.1.jar
4、httpcore-4.2.2.jar
5、httpcore-nio-4.2.2.jar
6、neethi-3.0.2.jar
7、spring-aop-3.0.7.RELEASE.jar
8、spring-asm-3.0.7.RELEASE.jar
9、spring-beans-3.0.7.RELEASE.jar
10、spring-context-3.0.7.RELEASE.jar
11、spring-core-3.0.7.RELEASE.jar
12、spring-expression-3.0.7.RELEASE.jar
13、spring-tx-3.0.7.RELEASE.jar
14、spring-web-3.0.7.RELEASE.jar
15、wsdl4j-1.6.2.jar
16、xmlschema-core-2.0.3.jar
3)appliaction-server.xml:
<!--CXF配置 -->
<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" />
<!--服务端发布的webservice 在spring中使用jaxws:endpoint元素来暴露Web Service id:指在spring配置的bean的ID Implementor:指明具体的实现类Address:指明这个web service的相对地址 -->
<jaxws:endpoint id="helloWorld" implementor="com.ws.cxf.daoImpl.HelloWorldImpl"
address="/HelloWorld" />
4)接口:
@WebService
public interface IHelloWorld {
@WebMethod
public String sayHello(String name);
}