title: How to provide server address to the Spring-configured Apache CXF-based web service client?
body: <p>I'm experimenting with Apache CXF and have a question about the client part.</p>
  
  <p>Below is my current Spring configuration of the WS client of some <code>com.example.customerservice.service.CustomerService</code>:</p>
  
  <pre><code>&lt;jaxws:client
      name="com.example.customerservice.service.CustomerServiceClient"
      serviceName="customer:CustomerServiceService" endpointName="customer:CustomerServiceEndpoint"
      address="http://localhost:8080/CustomerServicePort"
      serviceClass="com.example.customerservice.service.CustomerService"&gt;
      &lt;jaxws:features&gt;
          &lt;bean class="org.apache.cxf.feature.LoggingFeature" /&gt;
      &lt;/jaxws:features&gt;
  &lt;/jaxws:client&gt;
  </code></pre>
  
  <p>As you see, the <code>address</code> attribute is configured statically. This is not suitable for me because I don't know the server URL in advance. Moreover, in certain scenarios I'd like to use this client for different services which have different addresses.</p>
  
  <p>Therefore static configuration of the server address in Spring is not appropriate. So my question is - how can I make it dynamic?</p>
  
  <ul>
  <li>At the moment my solution is to set a system property - something like <code>baseUrl</code> and inject it into the Spring config using the property placeholder configurer.</li>
  <li>Another possibility would be to simply construct the client manually which I don't really like either.</li>
  </ul>
  
  <p>But I believe I'm really missing something. Maybe there is a possibility of something like <code>clientFactory.createClientFor("http://myserver:8080")</code>?</p>