Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Service - Tomcat - Behind proxy - wsdl location

I have a Java webservice running on Tomcat in our internal environment. Let's say the wsdl is

http://actual:8080/app/temp?wsdl

To provide access to this webservice from outside the network, we created a proxy using Apache on another server and used ProxyPass to do something like

ProxyPass /app/temp http://actual:8080/app/temp

So externally when we access proxy/app/temp over http, it gets diverted to actual:8080/app/temp just fine. So no issues with that, and I can also access the wsdl.

But the WSDL has references to "actual" server for the "webservice location" on the port. This causes failure when an actual call is made to the webservice methods from a client.

Any ideas on how this can be fixed, please? Thanks.

Note: The client is generated using Metro. I found a way to force a different endpoint in the client using a code like below. But I am looking more for a pure proxy solution that we can do, instead of developers using our webservice having to touch their code.

((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://proxy/app/temp?wsdl");
like image 775
Arav Vijay Avatar asked Dec 29 '25 03:12

Arav Vijay


1 Answers

You can use the ProxyPreserveHost directive. Quoting from the directive's section in the link:

When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line

therefore you should have the following in your configuration file:

ProxyPreserveHost On
ProxyPass /app/temp http://actual:8080/app/temp

and then restart apache server. using this option, you will not need to change anything in web service related code or setup.