我正在尝试使用带有以下值的hashmap设置对象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打电话时,我没有收到回复。那么,我应该怎么做呢?
答案 0 :(得分: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。完整网址通常为http://localhost:8080/holidayService/holiday.wsdl