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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章