如何在 Spring Boot 中使用 Tuckey urlrewrite 来使用 ?wsdl 访问服务 [英] How to use Tuckey urlrewrite in spring boot to access service using ?wsdl

查看:91
本文介绍了如何在 Spring Boot 中使用 Tuckey urlrewrite 来使用 ?wsdl 访问服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My clients wanted to access wsdl using ?wsdl notation, but the springboot service i have created is working with only '.wsdl' format. I need a working example/sample how to configure Tuckey urlrewrite in the springboot application. I have tried using below code, but the application complaints as it cant find urlrewrite.xml (which i have placed in src/main/resources folder.

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

Q1: How can i make my service to be accessible using url below http://localhost:8080/ws/organisation?wsdl

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

I have tried using below code, but tuckey cannot find the urlrewrite.xml which is under src/java/resources.

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

推荐答案

我终于找到了解决方案.现在正在从 src/main/resources 文件夹中读取 urlrewrite.xml.

Finally I could figure out a solution. This is now reading urlrewrite.xml from the src/main/resources folder.

无需在问题帖子中声明上述bean定义(public FilterRegistrationBean tuckeyRegistrationBean()),因为下面声明为@Component的代码将自动注册到上下文并进行url重写.

No need to declare above mentioned bean definition in the question post (public FilterRegistrationBean tuckeyRegistrationBean()), as the below code declared as @Component will automatically register with context and url-rewriting is performed.

@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);
        }
    }
}

这篇关于如何在 Spring Boot 中使用 Tuckey urlrewrite 来使用 ?wsdl 访问服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆