在Spring Boot应用程序中配置了两个不同的SOAP Web服务端点

 新建一个CustomMessageDispatcherServlet类,以扩展以下MessageDispatcherServlet类,

import org.springframework.ws.transport.http.MessageDispatcherServlet;

import javax.servlet.http.HttpServletRequest;

public class CustomMessageDispatcherServlet extends MessageDispatcherServlet {

    @Override
    protected 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 messageDispatcherServlet() {
    CustomMessageDispatcherServlet servlet = new CustomMessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean<>(servlet, "/ws/*");
}

你可能感兴趣的:(java,spring,boot)