---
title: "CXF整合Spring 1"
author: "stondeng"
date: "2012-01-19T12:37:07Z"
tags: ["Spring", "WebService", "cxf"]
categories: ["编程语言"]
slug: "cxf-spring-1"
draft: false
lastmod: "2012-01-19T13:25:54Z"
id: 1358319
url: "https://stonedeng.iteye.com/blog/1358319"
---

一、创建一个工程，添加如下jar包 cxf-2.5.1.jar wsdl4j-1.6.2.jar xmlschema-core-2.0.1.jar jetty-server-7.5.3.v20111011.jar jetty-util-7.5.3.v20111011.jar jetty-continuation-7.5.3.v20111011.jar jetty-http-7.5.3.v20111011.jar jetty-io-7.5.3.v20111011.jar neethi-3.0.1.jar 另外再添加发布包中与spring有关的jar 二、服务器端 1、web.xml \[code="java"] cxf-first contextConfigLocation classpath:\*bean.xml org.springframework.web.context.ContextLoaderListener CXFServlet org.apache.cxf.transport.servlet.CXFServlet 1 CXFServlet /cxftest/* \[/code] 2、接口类 \[code="java"] package cxf.spring.service; import javax.jws.WebParam; import javax.jws.WebService; @WebService public interface HelloWorld { public String sayhello(@WebParam(name="name")String name); } \[/code] 3、实现类 \[code="java"] package cxf.spring.service; import javax.jws.WebService; @WebService(endpointInterface="cxf.spring.service.HelloWorld") public class HelloWorldImpl implements HelloWorld { public String sayhello(String name) { return "Hello,"+name; } } \[/code] 4、bean.xml \[code="java"] \[/code] 5、启动tomcat并发布