Setting url dynamically for outbound gateway doesnt work
<p>I am trying to dynamically set the url for my outbound-gateway element, and it is not working for some reason. Everything worked fine before I tried to set it dynamically.</p>

<p>Here is the relevant part of the xml:</p>

<pre><code>&lt;int-http:outbound-gateway
        request-channel="sumTicketChannelOutput"
        url="{ticketsSum}"
        http-method="POST"
        uri-variables-expression="@uriVariableBean.populateTicketSumUrl(payload)"
        extract-request-payload="true"
        expected-response-type="mypackage.dto.bet.SlipAddTransactionsResultWrapper"&gt;
    &lt;/int-http:outbound-gateway&gt;
</code></pre>

<p>Note that I am using uriVariableBean in another gateway that has been defined in the same file, and that gateway works, so its definitely not a problem with importing that bean, I just have not pasted the code.</p>

<p>Here is the relevant code from the bean:</p>

<pre><code>@Value("${vfl.tickets.sum}")
private String defaultVirtualTicketsAddress;

@Value("${vfl.tickets.sum.ba}")
private String specialVirtualTicketsAddress;

public Map&lt;String, ?&gt; populateTicketSumUrl(Object payload) {

        Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();

        if (payload instanceof SlipDataRequest) {

            BetSlipDataRequest dataRequest = (SlipDataRequest) payload;

            Integer lcMemberId = dataRequest.getLcMemberId() != null ? dataRequest.getLcMemberId().intValue() : null;

            if (webUserService.isSpecial(lcMemberId)) {

                variables.put("ticketsSum", specialVirtualTicketsAddress);
            } else {

                variables.put("ticketsSum", defaultVirtualTicketsAddress);
            }

        } else {

            variables.put("ticketsSum", EXPRESSION_PARSER.parseExpression("headers.ticketsSum"));
        }

        return variables;
    }
</code></pre>

<p>The error I get when invoking an operation using the gateway is the following:</p>

<pre><code>org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Field or property 'ticketsSum' cannot be found on object of type 'org.springframework.integration.MessageHeaders'
</code></pre>

<p>Any insight on why this could be happening would be greatly appreciated, as I have went through the documentation and all the online posts I could find and still have absolutely no idea why this is happening.</p>