Announcement Announcement Module
No announcement yet.
Spring Integration - url-variable not working in http:outbound-gateway Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Integration - url-variable not working in http:outbound-gateway

    In order to send http request to dynamic urls based on message headers...

    I am trying to set the url value from Message header as follows:

    <int-http:outbound-gateway id="httpOutboundGateway" request-channel="fromMyQueue"
    url="{outboundGatewayUrl}" reply-channel="nullChannel"
    http-method="POST" expected-response-type="java.lang.String" charset="UTF-8">
    <int-http:uri-variable name="outboundGatewayUrl" expression="headers['X-CUSTOM-HTTP-REQUEST-URL']" />

    But this is not working.
    Apparently {outboundGatewayUrl} value is not being replaced i.e evaluated at all Or is my understanding of the issue not right?
    This works if i replace the {outboundGatewayUrl} with actual URL.

    Error Message:
    Caused by:
    org.springframework.integration.MessageHandlingExc eption: HTTP request execution failed for URI [{outboundGatewayUrl}]...

    Caused by:<br> java.lang.IllegalArgumentException: URI is not absolute
    at org.springframework.http.client.SimpleClientHttpRe questFactory.createRequest(SimpleClientHttpRequest

    What am i missing here?

  • #2
    You should use 'url-expression' attribute instead of 'url'


    • #3
      Bear in mind that's only available in 2.2.

      As I pointed out in the Stack Overflow question, the URI is not absolute error is produced if your uri variable expression resolves to null (e.g. if the header doesn't exist).


      • #4
        Just one other point - if your URL contains special characters (e.g. ?), it won't work properly and you have to use the technique that Oleg cited.