[英]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.