webservice与spring的集成

在web项目中做webservice与spring的集成,整理如下:


  第一步:首先搭建spring环境;

                1;在web.xml中的配置:

                 

  <!-- 配置spring的配置文件的加载位置 -->
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <!-- 配置spring的监听器 -->
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

              2;在项目的根目录下,记得创建applicationContext.xml的配置文件;


第二步:spring 与webservice的集成

         

                1;在web.xml中的配置

                  

  <!-- 配置cxf -->
  <servlet>
  	<servlet-name>hello</servlet-name>
  	<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
  	<load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  	<servlet-name>hello</servlet-name>
  	<url-pattern>/WS/*</url-pattern>
  </servlet-mapping>

                2;接着在applicationContext.xml中配置cxf

               

              

<?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-3.0.xsd
	    http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
		
		<!-- 导入cxf的配置文件 -->
		<import resource="classpath:META-INF/cxf/cxf.xml" />
		<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

              3;就是如何发布 和 如何消费接口;

                   在服务器端,在applicationContext.xml中配置:

                 

		<!-- 对外发布接口 -->
		<jaxws:server id="iserver" address="/iserver" serviceClass="cn.suaee.WebServiceImpl" >
		</jaxws:server>

                   在客户端,在applicationContext.xml中的配置:

                                 

		<!-- 创建客户端调用服务端的对象 -->
		<jaxws:client id="iclient" address="http://localhost:8080/web-s/WS/iserver" serviceClass="cn.suaee.IWebService">
		</jaxws:client>

马马虎虎就这样总结一下吧!不吝赐教!
具体代码,可以在这里下载哦!http://download.csdn.net/detail/u011079727/8150039
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值