微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

spring 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐