首页 > 代码库 > spring cxf 配置

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

spring cxf 配置