Search code examples
javaspringweb-serviceswsdlreverse-proxy

Spring Generated WSDL exposes wrong protocol (HTTP vs HTTPS) endpoint location


I have a Tomcat server running "behind" an Apache 2 (via mod_proxy), in the Tomcat there is a WAR serving Spring generated Webservices, which expose a service like this one:

<wsdl:service name="EcoboxPortService">
    <wsdl:port binding="tns:EcoboxPortSoap11" name="EcoboxPortSoap11">
        <soap:address location="http://host:80/ecobox-ws/Ecobox"/>
    </wsdl:port>
</wsdl:service>

The problem is that the WSDL is actually obtained by the following URL:

https://host/ecobox-ws/ecobox.wsdl (Please note it uses HTTPS)

Given the above 2 questions arise:

  1. Why does the WSDL add the '80' port to the endpoint location? Can it be overridden?
  2. Why does it get 'http' protocol, despite the actual URL requested was via 'https'? Doesn't Spring interpret 'X-forwarded-for' headers?

Similar question, but not entirely helpful: change the soap:address location in generated wsdl

Relevant dependencies:

    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.2.2.RELEASE</version>
    </dependency>

Relevant web.xml excerpt:

<servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

Solution

  • You might want to check your Tomcat configuration, where you'd need to set "proxyName" and "proxyPort". JAX-WS auto-generation should pick it up from there / the request-headers. More information here: http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html