【问题标题】:UriEndpointmapping working with attribute setendpointmapping - Spring Integration wsUriEndpointmapping 使用属性 setendpointmapping - Spring Integration ws
【发布时间】:2016-12-06 00:26:57
【问题描述】:

我正在尝试使用具有以下值的哈希图设置对象 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);

其中:gateway 是一个 int-ws:inbound-gateway 类型的 bean 而 wsdlDefinition 是一个返回 DefaultWsdl11Definition 的方法

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

【问题讨论】:

    标签: spring-integration spring-ws


    【解决方案1】:

    你有点误解了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>
    

    还有这句话:

    id 确定可以检索 WSDL 的 URL。在这种情况下,id 是holiday,这意味着可以在servlet 上下文中将WSDL 作为holiday.wsdl 检索。完整的 URL 通常是 http://localhost:8080/holidayService/holiday.wsdl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多