近些年来,Spring一直很火,许多框架都能跟Spring完美集成,CXF也不例外。下面,我就介绍一下如何使用CXF + Spring发布webService。我们还是使用前两篇博客使用的实例。
服务端:
目录结构:
这里需要的所有Spring的包,CXF的lib目录下都有。
IHelloWorldServer代码:
package com.test.server;
import javax.jws.WebService;
@WebService
public interface IHelloWorldServer {
public String sayHello(String username);
}
HelloWorldServerImp代码:
package com.test.server;
import javax.jws.WebService;
@WebService(endpointInterface="com.test.server.IHelloWorldServer",serviceName="HelloService")
public class HelloWorldServerImp implements IHelloWorldServer {
@Override
public String sayHello(String username) {
return username+" : HelloWorld";
}
}
applicationContext-server.xml
<?xml version="1.0" encoding="UTF-8&#