使用Mule更改url属性值

时间:2014-04-07 18:03:10

标签: mule flow

我正在尝试构建一个基于其值更改URL的应用程序。 我到目前为止的代码是:

<flow name="CalculadoraHttpsSoap12Endpoint" doc:name="CalculadoraHttpsSoap12Endpoint">
    <http:inbound-endpoint exchange-pattern="request-response" address="${serverName}/Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint/" connector-ref="" doc:name="HTTP"/>
    <http:outbound-endpoint address="${targetServer4}/Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint/" exchange-pattern="request-response"/>
</flow>

此代码仅从$ {serverName} /Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint获取消息并将其发送到$ {targetServer4} /Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint/但是我想要做的是如果某些消息是$ {serverName} /Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint?att=1234将其更改为$ {serverName} /Calculadora/services/Calculadora.CalculadoraHttpsSoap12Endpoint?att1=4567并将其发送到出站地点,任何线索或文章如何做到了吗?

Mule版本3.4.0

1 个答案:

答案 0 :(得分:1)

您可以获取查询字符串并定义变量:

<set-variable variableName="myAtt" value="#[message.inboundProperties['http.query.string'] == 'att=1234' ? '?att1=4567' : '']"/>
<set-variable variableName="myUrl" value="#[message.inboundProperties['http.query.string'] == 'att=1234' ? 'localhost' : '${targetServer4}']" />

<http:outbound-endpoint address="http://#[myUrl]/somepath/#[myAtt]" exchange-pattern="request-response"/>