Spring身份验证+CXF拦截器+RESTful

1.说明

     在项目开发过程中,可能读者会有这样的需求,那就是你需要提供接口供第三方系统来获取你们系统某个业务的信息。这样的需求其实是在支付系统会更为常见。笔者曾经做过某大型公司的支付系统的接口。我们需求提供大量的接口来供第三方系统来调用。这些接口的返回信息可以是json的格式,亦可是xml的。可能说了这么多,无非就是java中的一门技术,叫RESTful。笔者在博客已经写过SpringMVC的RESTful的用法,笔者可以了解一下。今天,我们将要学习如何使用Spring的框架和CXF的框架来实在拦截身份验证和接口提供提供。

2.CXF的拦截器

     一看到拦截器,我想读者可能最先想到的是Struts,是的Struts的拦截器是我们项目开发中最为常用的,但这里我们不讲Struts,我们主要是讨论CXF的拦截器.要想实例CXF的拦截器,我们需要引入cxf-2.3.6.jar架包。并且我们在加载Spring的时候,需要加载这个拦截器。笔者的Spring配置文件命名为applicationContext-webservice.xml。读者也可以自己命名。

<?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"
        xmlns:simple="http://cxf.apache.org/simple"
        xmlns:soap="http://cxf.apache.org/bindings/soap"
        xmlns:cxf="http://cxf.apache.org/core"
        xsi:schemaLocation="
          	http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
          	http://www.springframework.org/schema/beans
			http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
         	http://cxf.apache.org/bindings/soap 
         	http://cxf.apache.org/schemas/configuration/soap.xsd
          	http://cxf.apache.org/simple 
          	http://cxf.apache.org/schemas/simple.xsd
          	http://cxf.apache.org/jaxws 
          	http://cxf.apache.org/schemas/jaxws.xsd"> 
	<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" />
	<!-- 全局Bus(输入拦截器) -->
	<cxf:bus>
		<cxf:inInterceptors>
			<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
			<bean class="org.a
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值