title: Getting URL of an CXF endpoint
body: <h1>Situation</h1>
  
  <p>I'm deploying web services with Apache CXF 2.6.2 to a Tomcat server. I'm exporting the services using the CXFServlet and the following Spring based configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:jaxws="http://cxf.apache.org/jaxws"
         xsi:schemaLocation="
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;
      &lt;import resource="classpath:META-INF/cxf/cxf.xml"/&gt;
      &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml"/&gt;
  
      &lt;jaxws:endpoint id="test_endpoint"
                      implementor="org.xyz.TestImpl"
                      address="/test"/&gt;
  
      &lt;bean id="testBean" class="org.xyz.TestBean"&gt;
          &lt;property name="endpoint" ref="test_endpoint" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>In my example deployment the CXFServlet is using the relative path /service and for example the web service implemented by TestImpl class is available as <a href="http://domain.com/tomcat-context/services/test" rel="noreferrer">http://domain.com/tomcat-context/services/test</a>
  The TestBean class has an setter for endpoint and it is set by Spring.</p>
  
  <h1>Goal</h1>
  
  <p>I want to determine the address (URL) which is provided by the endpoint test_endpoint in the class TestBean using the endpoint field. The result should be excactly "http://domain.com/tomcat-context/services/test".</p>
  
  <h1>What I've tried</h1>
  
  <pre><code>log.info("Endpoint set to " + endpoint);
  log.info("Address: " + endpoint.getAddress());
  org.apache.cxf.jaxws.EndpointImpl ep = (org.apache.cxf.jaxws.EndpointImpl) endpoint;
  log.info("Other Address: " + ep.getBindingUri());
  log.info("Props: " + ep.getProperties());
  </code></pre>
  
  <p>but the result is just</p>
  
  <pre><code>Address: /Sachbearbeiter
  Other Address: null
  Props: {}
  </code></pre>
  
  <p>How can I get the full URL? Is there is a way without building it on my own?</p>