开发者

how to hide WSDL using CXF

开发者 https://www.devze.com 2023-01-30 17:57 出处:网络
i have developed a Java Web service using CXF, and Spring. due to security reasons, i would like to hide the WSDL, though the WS wil开发者_JAVA百科l still be available.

i have developed a Java Web service using CXF, and Spring. due to security reasons, i would like to hide the WSDL, though the WS wil开发者_JAVA百科l still be available. is there a way to do that using CXF?


You could add a servlet filter in web.xml that stops ?wsdl requests from being processed:

<filter>
    <filter-name>wsdlFilter</filter-name>
    <filter-class>com.mycompany.myWsdlFilterClass</filter-class>    
</filter>

<filter-mapping>
  <filter-name>wsdlFilter</filter-name>
  <url-pattern>*?wsdl</url-pattern>
</filter-mapping>

The doFilter() method would look like this:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
    ServletException {

  String queryString = ((HttpServletRequest) request).getQueryString();    
  if(queryString!=null && queryString.toLowerCase().startsWith("wsdl")){
    return; //the filter chain stops and request does not get processed
  }
  else{
    chain.doFilter(request, response);
  }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消