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);
}
}
精彩评论