William
William

Reputation: 101

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

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?

Upvotes: 1

Views: 5375

Answers (1)

tbriscoe
tbriscoe

Reputation: 160

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]"

Upvotes: 2

Related Questions