Web项目中使用Spring整合CXF发布Web Services
2012-11-08 22:15
585 查看
Spring的Web项目搭建就不再啰嗦了,直接说整合的关键步骤。
1、CXF的包需要导入到项目中
2、web.xml文件添加下面的内容
3、提供服务的接口和实现类
1)、接口
2)实现类
3、在spring的配置文件中添加如下内容
1)首先命名空间添加
和xsi:schemaLocation=后面添加
1、CXF的包需要导入到项目中
2、web.xml文件添加下面的内容
<servlet> <servlet-name>cxf</servlet-name> <display-name>cxf</display-name> <description>Apache CXF Endpoint</description> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cxf</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
3、提供服务的接口和实现类
1)、接口
package cn.luxh.app.ws; import javax.jws.WebService; @WebService public interface Calculator { int add(int num1,int num2); }
2)实现类
package cn.luxh.app.ws; import javax.jws.WebService; @WebService(endpointInterface="cn.luxh.app.ws.Calculator") public class CalculatorImpl implements Calculator{ @Override public int add(int num1, int num2) { return num1 + num2; } }
3、在spring的配置文件中添加如下内容
1)首先命名空间添加
xmlns:jaxws="http://cxf.apache.org/jaxws"
和xsi:schemaLocation=后面添加
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd[/code]
2)接着配置提供服务的endpoint<jaxws:endpoint id="calculator" implementor="cn.luxh.app.ws.CalculatorImpl" address="/Calculator" />
4、就这么简单,就可以发布一个Web Service服务了,看来CXF和Spring是完美的结合。
5、启动Web应用,访问:http://localhost:8080/CXFAPP/services/Calculator?wsdl 就可以看到wsdl的描述文件了。CXFAPP是我的web应用名称。
相关文章推荐
- 使用CXF+spring+restful创建一个web的接口项目
- Spring整合CXF发布Web Services
- 在 Web 容器中使用 Spring + CXF 发布 WS(一)
- webservice之cxf实现[web项目中基于maven与spring整合]
- Web应用中使用CXF不基于Spring的WebService发布
- 使用cxf发布rest服务接口,和spring的整合
- thymeleaf :springboot整合mybatis的web项目中使用html而不是jsp当页面渲染
- Spring 集成CXF框架发布Webservice服务 和 使用jdk生成Webservice clinet
- 对于web项目单独使用struts,不和Spring整合的情况。
- 在 Web 容器中使用 Spring + CXF 发布 WS(二) --SOAP 及其安全控制
- spring整合mina开发web项目和简单mina客户端的使用
- 在web项目中使用cxf开发webservice,包含spring支持
- CXF3.0.4与spring整合开发Webservice功能的web项目
- 使用CXF+spring+restful创建一个web的接口项目
- 使用CXF+spring创建一个web的接口项目
- 使用CXF+spring创建一个web的接口项目
- 使用cxf整合spring发布webservice
- 使用CXF+spring+restful创建一个web的接口项目
- MyBatis学习总结(八)——Mybatis3.x与Spring4.x整合 一、搭建开发环境 1.1、使用Maven创建Web项目 执行如下命令: mvn archetype:create
- (五)CXF整合Spring发布RESTful风格的Web服务