Mule: How to dynamically set a url on an http request endpoint

僤鯓⒐⒋嵵緔 提交于 2019-12-13 19:33:13

问题


Using the deprecated http implementation it was possible to dynamically set the url on an outbound http endpoint from the payload or properties:

<http:outbound-endpoint address="http://#[payload]" method="GET" />

Is it possible to do this using the new http request connector?


回答1:


Yes, it is. Here is a simple example:

<http:request-config 
    name="HTTP_Request_Configuration" 
    host="#[flowVars.address]" 
    port="80" 
    basePath="/" 
    doc:name="HTTP Request Configuration"/>

<flow name="httpFlow">

    ...

    <set-variable 
        variableName="address" 
        value="#[message.inboundProperties.'http.query.params'.site]" 
        doc:name="Set site address variable"/>

    <http:request 
        config-ref="HTTP_Request_Configuration" 
        path="/" 
        method="GET" 
        doc:name="Get dynamic HTTP"/>
</flow>

Just define the host attribute using the MEL expression you require.

host="#[flowVars.someVariable]"



来源:https://stackoverflow.com/questions/37462195/mule-how-to-dynamically-set-a-url-on-an-http-request-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!