Announcement Announcement Module
Collapse
No announcement yet.
Spring Integration - url-variable not working in http:outbound-gateway Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 java.net.URI.toURL(URI.java:1080)
    at org.springframework.http.client.SimpleClientHttpRe questFactory.createRequest(SimpleClientHttpRequest Factory.java:109)


    What am i missing here?

  • #2
    You should use 'url-expression' attribute instead of 'url'
    See https://jira.springsource.org/browse/INT-2570

    Comment


    • #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).

      Comment


      • #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.

        http://stackoverflow.com/questions/1...tbound-gateway

        Comment

        Working...
        X