新建一个CustomMessageDispatcherServlet类,以扩展以下MessageDispatcherServlet类,
import org.springframework.ws.transport.http.MessageDispatcherServlet;import javax.servlet.http.HttpServletRequest;public class CustomMessageDispatcherServlet extends MessageDispatcherServlet {@Overrideprotected String transformWsdlLocation(HttpServletRequest request, String wsdlLocation) {String requestUri = request.getRequestURI();if (requestUri.contains("/WebservicesConnector/services/countries")) {return "countries.wsdl";} else if (requestUri.contains("/FinancingService/FinancingUpdate.asmx")) {return "kinsai.wsdl";}return super.transformWsdlLocation(request, wsdlLocation);}
}
そして、messageDispatcherServlet
メソッド内で、新しいカスタムのMessageDispatcherServlet
を設定します。
@Bean
public ServletRegistrationBean<CustomMessageDispatcherServlet> messageDispatcherServlet() {CustomMessageDispatcherServlet servlet = new CustomMessageDispatcherServlet();servlet.setApplicationContext(applicationContext);servlet.setTransformWsdlLocations(true);return new ServletRegistrationBean<>(servlet, "/ws/*");
}