UriEndpointmapping 使用属性 setendpointmapping - Spring Integration ws

UriEndpointmapping working with attribute setendpointmapping - Spring Integration ws

我正在尝试设置 属性 对象 UriEndpointmapping 的 setendpointmapping 以及具有以下值的散列图:

UriEndpointMapping uriEndpointMapping = new UriEndpointMapping();
Map<String,Object> endpointMap = new HashMap<>();
endpointMap.put("/miservicio/cliente", gateway);
endpointMap.put("/miservicio/cliente.wsdl", wsdlDefinition());
uriEndpointMapping.setEndpointMap(endpointMap);

其中:网关是一个类型为 int-ws:inbound-gateway 的 bean wsdlDefinition 是 return DefaultWsdl11Definition

的方法

所以,当我从浏览器 localhost:8080/miservicio/cliente.wsdl 调用时,我没有得到响应。那么,我该如何操作呢?

你有点误解了UriEndpointMapping逻辑:

 * Implementation of the {@code EndpointMapping} interface to map from the full request URI or request URI path to
 * endpoint beans.

WSDL 定义逻辑有点不同,它的完成类似于 MessageDispatcherServlet 启动逻辑的一部分:

private void initWsdlDefinitions(ApplicationContext context) {
    wsdlDefinitions = BeanFactoryUtils
            .beansOfTypeIncludingAncestors(context, WsdlDefinition.class, true, false);

传入请求的 WSDL 选择逻辑如下:

protected WsdlDefinition getWsdlDefinition(HttpServletRequest request) {
    if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) &&
            request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) {
        String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI());
        return wsdlDefinitions.get(fileName);
    }
    else {
        return null;
    }
}

让我们从 Spring WS 文档中获取一些示例:

<sws:dynamic-wsdl id="holiday"    
    portTypeName="HumanResource"
    locationUri="/holidayService/"
    targetNamespace="http://mycompany.com/hr/definitions"> 
  <sws:xsd location="/WEB-INF/hr.xsd"/>
</sws:dynamic-wsdl>

和这句话:

The id determines the URL where the WSDL can be retrieved. In this case, the id is holiday, which means that the WSDL can be retrieved as holiday.wsdl in the servlet context. The full URL will typically be http://localhost:8080/holidayService/holiday.wsdl