如何:配置 Spring-WS 以发布带有“?WSDL"样式 URL 的 WSDL 文件? [英] Howto: Configure Spring-WS to publish WSDL files with a '?WSDL' style URL?
问题描述
我正在尝试使用 Mule ESB 配置网络服务代理.
I am trying to configure web service proxying using Mule ESB.
我正在尝试使用 Mule 的 WSProxyService 来执行此操作,但在逐步执行相应的代码(使用调试器)后,很明显该类替换了端点地址.
I am attempting to do this using Mule's WSProxyService, but after stepping through the corresponding code (with the debugger), it is clear that this class replaces endpoint addresses.
问题是 Spring-WS WSDL 地址的样式是 http://xxxx/xxxx.wsdl,但 WSProxyService 需要 http://xxxx/xxxx?wsdl 或 http://xxxx/xxxx&wsdl.它将远程端点地址替换为本地 WSDL 地址;它在问号处切断远程 WSDL 地址,即?WSDL"旨在被切断,因此创建搜索词.但是因为 Spring-WS,这行不通.
The problem is Spring-WS WSDL addresses are of the style http://xxxx/xxxx.wsdl, but WSProxyService expects http://xxxx/xxxx?wsdl or http://xxxx/xxxx&wsdl. It replaces the remote endpoint addresses with the local WSDL address; it cuts the remote WSDL address at the question mark i.e. '?WSDL' is intended to be chopped off, so to create the search term. But because of Spring-WS, this does not work.
分解:
WSProxyService 最终尝试使用
WSProxyService ends up trying to use
http://xxxx/xxxx.wsdl
替换
http://xxxx/xxxx
与
http://yyyy/yyyy
失败...导致实际的 Web 服务调用直接进行,而不是通过代理.
which fails... leading to actual web service call going direct and not through the proxy.
有没有人注意到/解决过这个问题??
Has anyone ever noticed/solved this problem??
干杯,达伦
推荐答案
Spring WS servlet 前面的 servlet 过滤器如何检查 url 和 params?
How about a servlet filter in front of the Spring WS servlet that checks the url and the params?
如果匹配,则返回 WSDL,否则就让请求通过,就好像什么都没发生一样.
In case of a match, you return the WSDL, otherwise you let the request through as if nothing happened.
这应该很容易实现并且可以满足您的需求,如果您绝对必须将 WS + ?WSDL 的 url 附加到它.
This should be trivial to implement and will fill your need, if you absolutely must have the url of the WS + ?WSDL appended to it.
代码如下:
public class WsdlQueryCompatibilityFilter implements Filter {
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
// do nothing
}
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
throws IOException, ServletException {
final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
if ("GET".equals(httpServletRequest.getMethod())
&& "wsdl".equalsIgnoreCase(httpServletRequest.getQueryString())) {
httpServletRequest.getSession().getServletContext().getRequestDispatcher("/ws.wsdl")
.forward(request, response);
} else {
chain.doFilter(request, response);
}
}
@Override
public void destroy() {
// do nothing
}
}
这篇关于如何:配置 Spring-WS 以发布带有“?WSDL"样式 URL 的 WSDL 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!