How to hide WSDL using CXF

I developed a Java web service using CXF and Spring. due to security concerns, I would like to hide the WSDL, although WS will still be available. is there any way to do this using CXF?

+4
source share
1 answer

You can add a servlet filter to web.xml that stops processing wsdl requests:

<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 will 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); } } 
+2
source

Source: https://habr.com/ru/post/1332357/


All Articles