因为spring汇总获取wsdl的方式一般都是localhost:8080/appName/ws/appAPI.wsdl的方式,但是需求是需要写成之前的写法
localhost:8080/appName/ws/appAPI?wsdl,这里提供的方法是转发一下过来的请求,代码如下:
@Component
public class WsdlQueryCompatibilityFilter extends OncePerRequestFilter
{
@Override
protected void doFilterInternal( HttpServletRequest request, HttpServletResponse response, FilterChain filterChain )
throws ServletException, IOException
{
if ( "GET".equals( request.getMethod() ) && "wsdl".equalsIgnoreCase( request.getQueryString() ) )
{
request.getSession().getServletContext()
.getRequestDispatcher( "/ws" + StringUtils.substringAfter( request.getRequestURI(), "/ws" ) + ".wsdl" )
.forward( request, response );
}
else
{
filterChain.doFilter( request, response );
}
}
}
记录下来以供自己以后学习使用,也希望可以帮助需要的人。