Results 1 to 8 of 8

Thread: http outbound channel adapter does not follow redirect

  1. #1
    Join Date
    Dec 2012
    Posts
    8

    Default http outbound channel adapter does not follow redirect

    Hi,

    in the case I'm trying to address, I receive a call from a third party system that I handle using Spring Integration 2.2.0. After processing the message I have to call back the third party making a rest call to delete or update an entry. The third party server responds with a 302 and a Location header but the http outbound gateway or the channel adapters don't follow the redirect.

    <int:chain input-channel="out2" output-channel="nullChannel">
    <int:service-activator expression="aCorrectExpressionWasHere"/>
    <int-http:outbound-gateway
    url-expression ="headers.alertUrl"
    http-method="PUT" reply-channel="nullChannel"
    expected-response-type="java.lang.String" />
    </int:chain>

    any idea what I might be doing wrong?

    Best regards,

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    735

    Default

    Hello!

    So, do you mean that your 'headers.alertUrl' is an URL where you have to send your PUT request?
    What problem are getting?
    Have you debuged it?
    Do you have some Exception?

    Sorry, now it isn't clear what's going on.

    By design everything looks good.

    Take care,
    Artem

  3. #3
    Join Date
    Dec 2012
    Posts
    8

    Default

    Quote Originally Posted by Cleric View Post
    Hello!

    So, do you mean that your 'headers.alertUrl' is an URL where you have to send your PUT request?
    What problem are getting?
    Have you debuged it?
    Do you have some Exception?

    Take care,
    Artem
    Hi Artem,

    Thanks for your reply.

    For the first question, you are right. The URL is Ok and the rest template properly sends the request to the destination and gets an answer. The reply from the server is a 302 (the object at the rest URL has been properly found) and a Location header with the same exact URL I passed the first time. The third party server expects me to recall the URL to confirm update. This should work fine and it does work fine with curl-like clients. However the gateway doesn't finish it's job by sending the new request has it should in reply to the 302 redirect.

    I did a temporary workaround for this by setting a channel after the first request and emitting myself a new request. But it should work without this :S

    Regards,
    Fabrice

  4. #4
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    735

    Default

    OK, I'll take a look and let you know

  5. #5
    Join Date
    Dec 2012
    Posts
    8

    Default

    Quote Originally Posted by Cleric View Post
    OK, I'll take a look and let you know
    Great thanks !

  6. #6
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    735

    Default

    Take a look here, please: http://forum.springsource.org/showth...n-resttemplate
    and here: https://jira.springsource.org/browse/SPR-5653
    So, the main solution: don't use follow redirects at all.
    But it is up to you: by default RestTemplate allows FollowRedirects only for GET.
    Nevertheless you can implement your own one.
    And this task is out of scope of Spring Integration...

    Cheers!

  7. #7
    Join Date
    Dec 2012
    Posts
    8

    Default

    Quote Originally Posted by Cleric View Post
    Take a look here, please: http://forum.springsource.org/showth...n-resttemplate
    and here: https://jira.springsource.org/browse/SPR-5653
    So, the main solution: don't use follow redirects at all.
    But it is up to you: by default RestTemplate allows FollowRedirects only for GET.
    Nevertheless you can implement your own one.
    And this task is out of scope of Spring Integration...

    Cheers!
    Yes I saw this page. But as Arjen said it was fixed I thought that it followed redirects for any method. I was hoping not to have to write a single line of code.

    I'll do what you suggest, thanks !

  8. #8
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    735

    Default

    No, Arjen said a bit different: just re-read https://jira.springsource.org/browse/SPR-5653.

Posting Permissions

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