Java – How to change the autogenerated soap:address from a JAX-WS webservice WSDL deployed with Spring

javajax-wsspringweb services

I have a webservice implementation generated using wsimport from a WSDL. This service is deployed in a Tomcat server in a Spring webapp. The spring configuration file (only the webservice part) is like this

<wss:binding url="/fooService">
    <wss:service>
        <ws:service bean="#fooService">
    </wss:service>
</wss:binding>

When I deploy this webapp in tomcat, I can get the WSDL if I go to

http://localhost:8080/foo/fooService?wsdl 

and the wsdl soap:address property is like this:

<service name="FooService">
    <port name="FooService" binding="tns:FooServiceBinding">
        <soap:address location="http://localhost:8080/foo/fooService"/>
    </port>
</service>

And for now, it's all ok.

The problem is that in production, we have an Apache web server and this server redirects the requests to Tomcat. It works too, but when we get the WSDL, the soap:address is still localhost:8080 and we need this to be the public url to the webservice.

Any ideas?

Thank you very much.

Best Answer

Well, I've found one solution:

It seems that JAX-WS generates this property automatically. I've found that other webservice frameworks implementations, allow the user to change this by hardcoding the url in a property, but it seems that JAX-WS doesn't. Somebody knows if there is some way?

Anyway, I've found a workaround: Using proxyName and proxyPort properties in tomcat Connector configuration, you can tell Tomcat that is behind a proxy (in our case, Apache server) and that the "real" port for the clients is 80.

Doing this change, the autogenerated soap:address contains the correct value.

References: