如何过滤webservice调用者的ip

1.在工程的web.xml中,会有webservice的配置如axis的配置;
只要在在axis配置之前,加入我们自己的filter即可(过滤路径要与axis的一样),可以对应多个filter-mapping

例子:
              //自己的filter
              <filter>
  
  <filter-name>PathFilter</filter-name>
  <filter-class>com.huawei.filter.PathFilter</filter-class>
              </filter>
 <filter-mapping>
  <filter-name>PathFilter</filter-name>
  <url-pattern>/servlet/AxisServlet</url-pattern>
 </filter-mapping>                
               <filter-mapping>
  <filter-name>PathFilter</filter-name>
  <url-pattern>/services/*</url-pattern>
 </filter-mapping> 
                <filter-mapping>
  <filter-name>PathFilter</filter-name>
  <url-pattern>*.jws</url-pattern>
 </filter-mapping> 


             //下面是axis的servlet配置
                <servlet>
  <servlet-name>AxisServlet</servlet-name>
  <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>AxisServlet</servlet-name>
  <url-pattern>/servlet/AxisServlet</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>AxisServlet</servlet-name>
  <url-pattern>/services/*</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>AxisServlet</servlet-name>
  <url-pattern>*.jws</url-pattern>
 </servlet-mapping>

2.过滤就是允许那些用户调用我们的接口,这些ip写在配置文件里(可以是多个或一个)

posted @ 2012-08-31 11:50  嗨,你的益达~~~  阅读(1956)  评论(0编辑  收藏  举报