eranl
eranl

Reputation: 41

how to hide WSDL using CXF

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 will still be available. is there a way to do that using CXF?

Upvotes: 4

Views: 3459

Answers (1)

Arnelism
Arnelism

Reputation: 1514

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);
  }

}

Upvotes: 3

Related Questions