title: Getting address of Java web service within the web service itself
body: <p>Let's say, I am hosting a Java web service at <code>http://dev01:8080/ABC/theWS</code>. The web service is implemented using JAX-WS and JAXB annotations.</p>
  
  <p>How do I get the address (<code>http://dev01:8080/ABC/theWS</code>) from within the web service itself, in order to use the address within the web service programmatically?</p>
  
  <p>The web service is hosted in Tomcat, and was deployed as a war file.</p>
  
  <ul>
  <li><code>dev01:8080</code> is the root.</li>
  <li><code>ABC</code> is the name of the war file.</li>
  <li><code>`theWS</code> comes from the <code>/META-INF/web.xml</code>, something that I can defined it.</li>
  </ul>
  
  <p>I may have complete control over the server and the war file, so I can just hard code the address. However, this is what I don't want to do.</p>
  
  <p>I know how to get the host name, but not the port and the rest of them.</p>