December 2, 2011

Apache, Glassfish and JAX-WS

Install

Environment: Apache, Glassfish 3.1.1 (or here) on Ubuntu server 11.04, behind FW with VIP.  Here is the good tutorial on installing Glasfish on Ubuntu.


Start/Stop commands for Glassfish:

glassfish/bin/asadmin stop-domain domain1
glassfish/bin/asadmin start-domain domain1


- For virtual hosting, this page might be a good help.
- For SSL, see this page.

Apache + Glassfish

Usual Reverse Proxy configuration will work fine:

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/


JAX-WS (Web Service) "soap:address location" Issue

My apache server is behind a firewall, and has a VIP, then using apache reverse proxy to Glassfish.  May be this set up is the cause of my problem, but I was getting the IP in ProxyPass/ProxyPassReverse in the JAX-WS's WSDL page for soap-address:location:
<soap:address location="http://127.0.0.1/myapp/mywebservice"/>

This is a problem for client to generate WS client codes using the WSDL.  I spent good amount of time Googling for the solution and found a few things:
1. it's been reported as a bug and is supposed to be fixed before 3.1.1.  May be my problem is caused by my environment: FW and VIP.
2. someone actually wrote servlet filtering to intercept the output, and regex the host name to change it to a correct one.
3. another solution was to grab the generated WSDL, save it locally, hand edit it, then upload.

#2 and #3 are all hacks and I applaud for the developers effort, but I did not like those solution because I am too lazy to do any workaround coding for some environmental issue, and do hand edit things each time WSDL is updated.  So did more digging and reading, found a simpler solution.  In the Apache config for the reverse proxy, just add one more line and it would look like this:

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/



I hope this little finding saves other developers' time.

No comments: