Results 1 to 10 of 10

Thread: http:outbound-gateway - Resttemplate method

  1. #1

    Default http:outbound-gateway - Resttemplate method

    I am trying to invoke a rest service from SI using http:outbound-gateway. When I look at the source code of SI, I believe that it in turn using RestTemplate.exchange method in org.springframework.integration.http.HttpRequestEx ecutingMessageHandler class.

    There is an issue with the 3rd party rest service. When I try to execute using resttemplate exchage method with http method "GET", it give an http page as response, instead of the xml response. However, if I use Resttemplate getForObject method, it worked properly and gave proper xml response. The same html response is getting returned if I use SI because it uses Resttemplate exchange method.
    Is there any work around in SI? Can I somehow ask SI to use Resttemplate getForObbject method in http:outbound-gateway?

    Or Is there any way to change the resttemplate method that is use in http:outbound-gateway?

    Thanks.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Could you please post the gateway configuration?
    Also, when executing RestTemplate.exchange(..) method what type of 'responseType' type you provide?

  3. #3

    Default

    Below is my gateway configuration:
    <int-http:outbound-gateway id="example" request-channel="requests" url="http://localhost/test" http-method="GET" expected-response-type="java.lang.String"
    reply-channel="replies"/>

    Is there any way to change the Resttemplate method getting invoke?

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    When you invoke getForObject() method what 'responseType' do you provide?

  5. #5

    Default

    Yes. This is the method that I invoked from RestTemplate class
    public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables)

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    PLease read my question again since you did not answer it. What is the type of the 'responseType' you are providing to the above method?

  7. #7

    Default

    It is the same java.lang.String only

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

    Default

    Hi!
    Which "Content-Type" are you getting from Response?
    And maybe you are sending some "Accept" from you SI-flow...
    Can you DEBUG both scenarios (SI and direct Resttemplate) and say us what's going on? Where Spring Integration is not right .
    And which version of Spring Integration & Spring Web do you use?

    Take care,
    Artem

  9. #9

    Default

    As I mentioned earlier, I have used Resttemplate directly for debugging. When I invoke using RestTemplate.exchange, it returned the client request html page. I have tried with all kind of content-type and accept in the header.
    Now I have invoked using RestTemplate.getForObject method, I get the proper xml response. So, I believe the resttemplate.exchange is not working properly for my rest service.

    So my question is, as SI used RestTemplate.exchange method in http:outbound-gateway, is it possible to invoke some other method provided by RestTemplate class in SI? If not, then do you not think that you should provide this, as RestTemplate class has in turned so many public methods?

    I am using spring integration 2.1.0 version.
    Last edited by Mission; Dec 5th, 2012 at 10:18 AM.

  10. #10
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    645

    Default

    So, I believe the resttemplate.exchange is not working properly for my rest service.
    Well, there is some difference between 'getForObject' & 'exchange': AcceptHeaderRequestCallback for first one and HttpEntityRequestCallback for other.
    So, that's why I ask you to debug it.
    And I believe you're sending some headers to the service by which he means that he should send you back HTML instead of XML...

Posting Permissions

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