I'm experimenting with Apache CXF and have a question about the client part.
Below is my current Spring configuration of the WS client of some com.example.customerservice.service.CustomerService
:
<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">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:client>
As you see, the address
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.
Therefore static configuration of the server address in Spring is not appropriate. So my question is - how can I make it dynamic?
- At the moment my solution is to set a system property - something like
baseUrl
and inject it into the Spring config using the property placeholder configurer. - Another possibility would be to simply construct the client manually which I don't really like either.
But I believe I'm really missing something. Maybe there is a possibility of something like clientFactory.createClientFor("http://myserver:8080")
?