Skip to content

LocationTransformerObjectSupport#transformLocation should not append port if it is already present #1420

Closed
@rafaello7

Description

@rafaello7

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions