WSDL location transform: use of X-Forwarded-* headers under Apache web server produces invalid URL
rafaello7 opened this issue · 0 comments
rafaello7 commented
HTTP forwarding in Apache web server does not add X-Forwarded-Port header. Instead, the X-Forwarded-Host header provides both host and port in format host:port. For such headers combination the URL transformed by LocationTransformerObjectSupport
class is invalid - it contains host name followed by two port numbers: one from the X-Forwarded-Host header and second one from request.
Example: for the configuration below:
@Configuration
@EnableWs
public class WebServiceConfig {
@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<>(servlet, "/HelloService/*");
}
@Bean(name = "HelloService")
public Wsdl11Definition messageServiceWsdlDefinition() {
return new SimpleWsdl11Definition(new ClassPathResource("/HelloService.wsdl"));
}
}
The HelloService.wsdl
contains:
<service name='HelloService'>
<port binding='tns:HelloServiceBinding' name='HelloServicePort'>
<soap:address location='http://www.example.com/HelloService/HelloService'/>
</port>
</service>
The http headers in request are as follows:
X-Forwarded-Proto: https
X-Forwarded-For: 192.168.1.1
X-Forwarded-Host: srv58:4436
X-Forwarded-Server: srv58
The resulting WSDL contains:
<service name="HelloService">
<port binding="tns:HelloServiceBinding" name="HelloServicePort">
<soap:address location="https://srv58:4436:8080/HelloService/HelloService"/>
</port>
</service>