Search code examples
springweb-servicesjax-wscxfspring-el

How to configure address in JAX-WS CXF Client using JNDI lookup


I am looking up my JNDI value of endpoint (properties file is not an option) on server like this

<jee:jndi-lookup id="MyEndpoint" jndi-name="endpoint.url" />

I would like to use the above looked up value in the place of address.

<jaxws:client id="helloClient"
       serviceClass="demo.spring.HelloWorld"
       address="http://localhost:9002/HelloWorld" />

I tried address="${MyEndpoint}". Did n't work. Looks like I have to use another bean, which uses jndi value and use its method to return as string i.e. address="#{MyBean.geyMyEndpoint()}". Doesn't look clean that way. Any suggestions?


Solution

  • You should be able to use Spring Expression Language to get the behavior you want, without using another bean. The following works for me in Tomcat 7:

    <jee:jndi-lookup id="MyEndpoint" jndi-name="java:comp/env/MyEndpoint" />
    
    <jaxws:client id="helloClient"
           serviceClass="demo.spring.HelloWorld"
           address="#{MyEndpoint}" />