繁体   English   中英

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

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

我使用spring boot ws应用程序和apache cxf一起提供SOAP Web服务。 所有配置的URL都使用相对路径,因此该应用程序可以与灵活的部署一起使用。

在生产环境中,该应用程序在负载平衡器后面运行,并强制客户端使用https。 但是尽管wsdl本身是使用https公开的,但是生成的wsdl仍保留其http协议。

这是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;
  }

如何调整生成的wsdl,以便切换到https? 或者更好:是否可以强制协议使用与暴露的wsdl本身相同的协议?

最好的,拉斯

我的项目中也遇到了类似的问题,我通过使用spring boot参数解决了这个问题。 我们有一个ngnix服务器,它接收请求并转发到具有Spring Boot应用程序的后端计算机。

在ngnix配置中添加了以下参数。

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

后来,在Spring Boot应用程序中添加了以下参数

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

此服务器开始将https附加到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);
    }
}

您需要在配置文件中像这样配置此拦截器。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM