【发布时间】:2015-04-28 21:41:56
【问题描述】:
我正在尝试为我的 SOAP 服务的 http 入站端点获取动态地址。
<http:inbound-endpoint exchange-pattern="request-response" address="#[app.registry.appversion.getNewAddress()]" doc:name="HTTP"/>
Spring 上下文有 bean 定义:
<bean id="appversion" class="com.visit.util.Application">
Application 类中的getNewAddress() 返回一个字符串。
但是,它会抛出异常:
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
看起来 MEL 没有被评估并被视为文字字符串。我错过了什么吗?任何帮助表示赞赏。提前致谢。
【问题讨论】:
-
尝试使用 Spring 表达式 (SpEL)。
-
@DavidDossot 您能否详细说明为什么您认为 SpEL 可以工作,我猜它与启动顺序有关,如果您能向我们解释一下就好了。
-
MEL 不会在任何地方进行评估,只会在它被编码的地方进行评估。 SpEL,因为 Mule 是建立在 Spring 之上的,所以有更多的机会在任何属性上工作。
-
@DavidDossot - 谢谢!那效果很好。
<http:inbound-endpoint exchange-pattern="request-response" address="#{appversion.getNewAddress()}" doc:name="HTTP"/>虽然不知道如何在评论中“竖起大拇指”,但感谢您的帮助。 -
我将这些 cmets 总结为下面的答案。