简体   繁体   English

cxf生成的wsdl:将肥皂地址位置协议更改为https

[英]cxf generated wsdl: change soap address location protocol to https

I use a spring boot ws application together with apache cxf to provide a SOAP web service. 我使用spring boot ws应用程序和apache cxf一起提供SOAP Web服务。 All configured URLs use relative paths, so that the application can be used with flexible deployments. 所有配置的URL都使用相对路径,因此该应用程序可以与灵活的部署一起使用。

In production environment, the application is running behind a load balancer and forces clients to use https. 在生产环境中,该应用程序在负载平衡器后面运行,并强制客户端使用https。 But the generated wsdl keeps its http protocol although the wsdl itself is exposed using https . 但是尽管wsdl本身是使用https公开的,但是生成的wsdl仍保留其http协议。

This is the spring endpoint configuration: 这是spring端点配置:

@Bean
  public Endpoint endpoint() {
    EndpointImpl endpoint = new EndpointImpl(springBus(), requestStatusApplicationService());
    RequestStatusReceiverService requestStatusReceiverService = requestStatusReceiverService();
    endpoint.setServiceName(requestStatusReceiverService.getServiceName());
    endpoint.setWsdlLocation(requestStatusReceiverService.getWSDLDocumentLocation().toString()); // also a relative path
    endpoint.publish("/relative-path-endpoint");
    return endpoint;
  }

How can I adjust the generated wsdl, so that it switches to https? 如何调整生成的wsdl,以便切换到https? Or better: is it possible to force the protocol to use the same like the exposed wsdl itself? 或者更好:是否可以强制协议使用与暴露的wsdl本身相同的协议?

Best, Lars 最好的,拉斯

I also faced a similar issue in my project, and I solved it by using spring boot parameters. 我的项目中也遇到了类似的问题,我通过使用spring boot参数解决了这个问题。 We have a ngnix server which takes the requests and forwards to back-end machines having spring boot applications. 我们有一个ngnix服务器,它接收请求并转发到具有Spring Boot应用程序的后端计算机。

Added following parameters in ngnix configuration. 在ngnix配置中添加了以下参数。

proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Scheme https;

Later, added following parameters in spring boot application 后来,在Spring Boot应用程序中添加了以下参数

server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.protocol-header=x-forwarded-proto

After this server started appending https to the URL. 此服务器开始将https附加到URL之后。

In your spring-boot application, if you are using cxf framework then you can add your custom interceptor to pass on the custom url. 在spring-boot应用程序中,如果使用cxf框架,则可以添加自定义拦截器以传递自定义URL。

public class MyInInterceptor extends AbstractInDatabindingInterceptor {

    private String url;

    public CustomInInterceptor(String url) {
        super(Phase.USER_STREAM);
        this.url = url;
    }

    @Override
    public void handleMessage(Message message) throws Fault {
        message.put("org.apache.cxf.request.url", url);
    }
}

You need to configure this interceptor like this in your config file. 您需要在配置文件中像这样配置此拦截器。

EndpointImpl endpoint = new EndpointImpl(bus, communicationPortTypeImpl);
List<Interceptor<? extends Message>> interceptors = new ArrayList<>();
interceptors.add(new MyInInterceptor(endpointUrl));
endpoint.setInInterceptors(interceptors);
endpoint.publish("/myEndPoint");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用JAX-WS更改运行时生成的WSDL中的schemaLocation和soap:address位置 - Change schemaLocation and soap:address location in runtime generated WSDL with JAX-WS 将 soap:address 位置从 http 更改为 https - change soap:address location from http to https 如何更改 WSDL soap 地址位置,尤其是 url 的上下文部分? - How to change WSDL soap address location , in particular the context part of the url? 如何使JAX-WS在生成的wsdl中使用https(http到https)作为soap:address - How to make JAX-WS use https (http to https) for soap:address in generated wsdl Spring生成的WSDL暴露了错误的协议(HTTP与HTTPS)端点位置 - Spring Generated WSDL exposes wrong protocol (HTTP vs HTTPS) endpoint location JBOSS EAP 6.4:不能在生成的 WSDL 中的“soap:address”中使用 HTTPS 模式 - JBOSS EAP 6.4: Can not use the HTTPS schema in “soap:address” in generated WSDL 如何在WSDL中动态设置SOAP地址的位置? - How to dynamically set the location of a SOAP address in a WSDL? CXF代码优先服务,WSDL生成; 肥皂:地址变更了吗? - CXF code first service, WSDL generation; soap:address changes? 如何在wsdl结束时更改soap地址 - How to change soap address at end of wsdl Apache CXF SOAP客户端,使用https中生成的存根 - Apache CXF SOAP client , using generated stubs in https
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM