码迷,mamicode.com
首页 > 编程语言 > 详细

spring cxf 配置

时间:2017-07-17 18:53:41      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:cxf


版本 -- cxf-2.5.2


<?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: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.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-servlet.xml" />

<!-- IP地址输入拦截器 -->  

<bean id="addressInInterceptor"  class="com.webservice.impl.util.AddressInInterceptor" />  

<!--  全局拦截器Bus  也可以使用局部拦截器配置-->

<!--

<cxf:bus>    

   <cxf:inInterceptors>    

       <ref bean="addressInInterceptor" />    

   </cxf:inInterceptors>    

</cxf:bus>  

--> 


<!-- 用户信息-->

<bean id="userDetailsServiceImpl" class="com.webservice.impl.UserDetailsServiceImpl"/>

<jaxws:endpoint    

id="userDetailsService"    

implementor="#userDetailsServiceImpl" 

implementorClass="com.webservice.impl.UserDetailsServiceImpl"

address="/userDetailsService" >

<jaxws:inInterceptors>  

<ref bean="addressInInterceptor" />  

</jaxws:inInterceptors>

</jaxws:endpoint> 

</beans>


地址拦截 白名单  




public class AddressInInterceptor extends AbstractPhaseInterceptor<Message> {  

@Resource

com.hotent.platform.service.system.SysAcceptIpService sysAcceptIpService;

    public AddressInInterceptor() {  

        super(Phase.RECEIVE);  

    }  

    

    /**

     *拦截器过滤方法。 

     */

    public void handleMessage(Message message) throws Fault {  

        HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);  

        String ipAddr=request.getRemoteAddr();

        if(!accept(ipAddr)) 

throw new Fault(new IllegalAccessException("ip地址" + ipAddr + " 拒绝访问"));        

    }  


}

    


访问地址: http://ip:port/project/service/SystemResourcesService?wsdl

spring cxf 配置

标签:cxf

原文地址:http://3971933.blog.51cto.com/3961933/1948168

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!