0

I am trying to get dynamic address for my http inbound endpoint for SOAP service.

<http:inbound-endpoint exchange-pattern="request-response" address="#[app.registry.appversion.getNewAddress()]" doc:name="HTTP"/>

Spring context has bean definition:

<bean id="appversion" class="com.visit.util.Application">

getNewAddress() in Application class returns a String.

However, it throws exception as:

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'protocol' threw exception; nested exception is java.lang.IllegalArgumentException: Address '#[app.registry.appversion.getNewAddress()]' for protocol 'http' should start with http://
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 38 more

Looks like the MEL is not being evaluated and is treated as a literal String. Am i missing something? Any help appreciated. Thanks in advance.

Pratik
  • 201
  • 5
  • 13
  • 1
    Try using a Spring Expression (SpEL) instead. – David Dossot Apr 27 '15 at 21:46
  • @DavidDossot can you elaborate on why you think SpEL could work, I am guessing it has something to do with startup sequence would be nice if you could explain it to us. – Sudarshan Apr 27 '15 at 22:49
  • 1
    MEL is not evaluated everywhere, only where it's been coded for. SpEL, because Mule is built on Spring, has more chance to work in any attribute. – David Dossot Apr 28 '15 at 02:16
  • 1
    @DavidDossot - Thanks! That worked wonderfully. `` Not sure how to give a "thumbs-up" in the comment though, but thanks for your help. – Pratik Apr 28 '15 at 12:34
  • I've summarized these comments as an answer below. – David Dossot Apr 28 '15 at 13:42

1 Answers1

2

Use a Spring Expression (SPeL) instead:

<http:inbound-endpoint exchange-pattern="request-response"
      address="#{appversion.getNewAddress()}" doc:name="HTTP"/>
David Dossot
  • 33,403
  • 4
  • 38
  • 72