3

I really need your help. I read that the wsdl for a jax-ws webservice will be generated on the fly for every request. By this, the addresses like the soap endpoint will be adjusted to the request url.

In my case it, no matter wheather internal or external request, the addresses are always refered to localhost:8080.

Does sb have a clue how can I handle this issue?

Thanks in advance


Maybe I haven't described my problem very well.

  1. I have a ws created with jax-ws
  2. Its deployed on a tomcat server 5.5.17
  3. Access with local ip works fine http://192.168.1.20:8070/mywebservice?wsdl
  4. Access with external ip doesn't work resp. the ws "engine" rewrites the url by using the local ip and not the external one external.domain.de:8070/mywebservice?wsdl

For external.domain all urls in the wsdl are rewritten to the local ip To the xsdschemaLocation and the soap:address location

Could the proxy server the problem? Request through the proxy makes the webservice think that it is an local access and not a external.

How can I prevent this behaviour on server side?Changes in web.xml or sun.jax (Changes on client side are regrettably not possible)

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
jaster
  • 33
  • 1
  • 3
  • possible duplicate of [How to change webservice url endpoint?](http://stackoverflow.com/questions/2490737/how-to-change-webservice-url-endpoint) - we have a very good answer there – Andreas Dolk Sep 19 '11 at 09:15
  • The two solutions from your linked thread uses a hardcoded URL. Thats not pretty neat. For deploying on other servers, the source code has to be edited and recompiled every time. Is there no option to set the endpoint url in the web.xml or the sun-jaxws.xml? That would be awesome. – jaster Sep 19 '11 at 11:12

1 Answers1

1

This is a classic problem when accessing web-services thru external proxies.

For this to work properly, you have to do the following

1) Add another HTTP connector in your Tomcat's server.xml. Say on port 8071, just copy the 8080 Connector Dfn. and set the port to 8071.

2) And in that Connector's defn. you have to add the external IP and Port as proxyHost and proxyPort.

i.e. your server.xml should contain one more Connector entry some thing like this

<Connector port="8071" protocol="HTTP/1.1"
   connectionTimeout="20000"
   redirectPort="8443"
   proxyHost="external.domain.de" proxyPort="8070" />

And make sure that Connections to external.domain.de on port 8070, get forwarded to 192.168.1.20 and port 8071, instead of 8070.

I told you to setup a new connector, assuming you would want to access the WS internally as well as externally. That way the internal port connector on 8070, does not use proxyhost and change the hostname for internal requests, but any requests coming from external sources via external.domain.de on port 8071 , will get the external.domain.de as hostname and 8070 as port.

If your WS is going to be accessed only from external clients, then you don't really need 2 connectors, just add the proxyHost and proxyPort directives to the 8070 connector and you're done. But be warned, that even internal requests, will now see the hostname as external.domain.de.

More info @ https://tomcat.apache.org/tomcat-5.5-doc/config/http.html#Proxy_Support