【问题标题】:Changing url attribute values using Mule使用 Mule 更改 url 属性值
【发布时间】:2014-04-07 18:03:09
【问题描述】:

我正在尝试构建一个根据 URL 值更改 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 并将其发送到出站位置,任何有关如何操作的线索或文章做吗?

骡子版本 3.4.0

【问题讨论】:

    标签: mule flow


    【解决方案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"/>
    

    【讨论】:

    • 您好,其中一些答案效果很好,但我的意思是现在我可以设置一个变量,甚至将其放入我的出站 url,我怎样才能将其值更改为合适的值,例如 myAtt = ' att1=1234&att2=5678' 现在将其更改为 myAtt = 'att1=asdf&att2=brdt' 并发送?
    • 对不起,我没有关注你。我的示例根据入站att=1234 参数动态设置值。那是最初的问题,对吗?如果您的查询字符串是其他内容,例如att1=1234&amp;att2=5678,只需替换我示例中的字符串即可。如果您想要更复杂的内容,请相应地更新您的原始问题。
    • 不,我认为它有效,我只需要使用表达式组件,除了设置变量及其所有工作,tyvm :)
    猜你喜欢
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多