Results 1 to 4 of 4

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

  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

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

  3. #3
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,037

    Default

    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).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,037

    Default

    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
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •