小编典典

如何在Spring Boot中使用Tuckey urlrewrite访问使用?wsdl的服务

spring-boot

我的客户希望使用?wsdl表示法访问wsdl,但是我创建的springboot服务仅使用’.wsdl’格式。我需要一个有效的示例/示例,该示例/示例如何在springboot应用程序中配置Tuckey
urlrewrite。我尝试使用下面的代码,但是应用程序抱怨它找不到urlrewrite.xml(我将其放置在src / main /
resources文件夹中。

问题1:如何使用http:// localhost:8080 / ws /
organisation下的
url来访问我的服务
?wsdl

我尝试使用下面的代码,但是tuckey找不到src / java / resources下的urlrewrite.xml。

@Bean
public FilterRegistrationBean tuckeyRegistrationBean() {
    final FilterRegistrationBean registrationBean = new ilterRegistrationBean();
    registrationBean.setFilter(new UrlRewriteFilter());
    registrationBean.addInitParameter("confPath", "urlrewrite.xml");
    return registrationBean;
}

阅读 391

收藏
2020-05-30

共1个答案

小编典典

最后,我可以找出解决方案。现在urlrewrite.xml从src / main / resources文件夹中读取。

无需在问题post(public FilterRegistrationBean tuckeyRegistrationBean())中声明上述bean定义,因为以下声明为的代码@Component将自动在上下文中注册并执行url重写。

@Component
public class WsdlUrlRewriteFilter extends UrlRewriteFilter {

    private static final String CONFIG_LOCATION = "classpath:/urlrewrite.xml";

    @Value(CONFIG_LOCATION)
    private Resource resource;

    @Override
    protected void loadUrlRewriter(FilterConfig filterConfig) throws ServletException {
        try {
            Conf conf = new Conf(filterConfig.getServletContext(), resource.getInputStream(), resource.getFilename(), "");
        checkConf(conf);
        } catch (IOException ex) {
            throw new ServletException("Unable to load URL-rewrite configuration file from " + CONFIG_LOCATION, ex);
        }
    }
}
2020-05-30