1

I'm having a problem on my work that I will need some help. I have a WebServiceTemplate configuration like below:

<bean id="serviceTest" class="org.springframework.ws.client.core.WebServiceTemplate">
    <property name="marshaller" ref="jaxbMarshallerOpe" />
    <property name="unmarshaller" ref="jaxbMarshallerOpe" />
    <property name="messageSender">
        <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
        </bean>
    </property>
    <property name="interceptors">
        <list>
            <ref bean="soapMessageInterceptor" />
        </list>
    </property>
    <property name="defaultUri" value="?????????????" />
    <constructor-arg ref="messageFactory" />
</bean>

My perfect cenário is to replace value="?????????????" with some value from database or to put there a value from a variable on my application. Is there a way to do that?

I really need a dynamic way to put the WSDL address there, because my client can change the service. Not frequently, but it's a possibility.

Does anyone knows how I can achieve this?

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127

2 Answers2

1

You can use the <context:property-placeholder> to resolve the real value from the provided Properties for that <context:property-placeholder>:

<property name="defaultUri" value="${web.service.url}" />

See more docs on the matter: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer

UPDATE

If you are going to change the defaultUri at runtime, you should inject the WebServiceTemplate bean to some service, which fetch the property, e.g. from DB and invoke setDefaultUri manually. It will work for any property provider: DB, file update, Web UI, JMX etc..

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • The problem with properties is that the client will not be able to edit, in run time. This solution would work for me with the properties could read information from the database, when the user update the information. Another question, since configuration reads from properties, if I change the value on the properties, the springws configuration will identify the change and reload the configuration automatically? Or I need to re-deploy the application to take efect? – Alexandre Soares Jul 18 '14 at 16:55
0

Take a look at the DestinationProvider interface. I think that's what you need.

Arjen Poutsma
  • 1,236
  • 9
  • 9