0

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?

pingu
  • 645
  • 3
  • 11
  • 21

2 Answers2

1

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}" />
Patrick
  • 2,102
  • 15
  • 11
  • Thanks Patrick. It seems address="#{MyEndpoint}" started working after I updated by imported XSDs to Spring v3.2. – pingu Feb 06 '14 at 00:02
0

Also on another note from Spring 3.1 - Spring has unified property management. so instead of the above solution you can do this

<jaxws:client id="helloClient"  serviceClass="demo.spring.HelloWorld"  address="${endpoint.url}" />

endpoint.url could be any property(system, environment etc) and it will automatically resolve the property. so no need to do separate JNDI lookup and your code looks clean.

pingu
  • 645
  • 3
  • 11
  • 21