Announcement Announcement Module
No announcement yet.
Outbound Http Gateway Issues Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Outbound Http Gateway Issues

    I upgraded from SI 1.0.4 to 2.0RC1. In upgrading my outbound http gateway I have discovered that it isn't working properly the way it did in 1.0.4.

    I send the output of the http gateway to a simple little servlet that logs the request and sends a simple response to pass to my request channel. My request channel gets invoked but the response body written by the remote servlet is not passed into the handler. An HttpStatus is, but the status is always 200 even though I have set it to different values, (202, 204 ...), on the server.

    I know my servlet is working because I can hit it via the browser, and the outbound soap gateway delivers its payload to it as well.

    Below is the configuration of my outbound http gateway. Am I missing something or is this a known issue?


    <http:outbound-gateway id="outboundHttpGateway"
    <http:uri-variable name="httpRequestUri" expression="headers['httpRequestUri']"/>

  • #2
    I have discovered that it isn't working properly the way it did in 1.0.4.
    I am not sure what do you mean by "properly", but yes its been completely re-factored from 1.0.4 version and is now based on REST support from Spring 3.0.
    Sp what I would suggest is to look at our samples
    and check out 'multipart-http' samples which has both in and outbound gateways and other goodies.

    Let us know if you still have issues.


    • #3
      My previous message was unclear. Let me try to clarify.

      In 1.0.4, the response that was sent back to my replyChannel's configured handler included the body of the remote server's http response. It looks like in 2.0, only an HttpStatus is returned to my replyChannel's handler.

      Perhaps there is a different configuration setting. I looked at those samples but they didn't prove that helpful in solving this problem. I'll take another look. If there is a quick and easy solution, that you aware of, let me know.



      • #4
        IN the examples I am defining Gateway method with HttpStatus as a return value simply because that is the only thing i care about for that sample.
        You can specify org.springframework.http.ResponseEntity instead and get everything you need.
        Give it a shot and let me know


        • #5
          Hi Oleg,

          Can you please provide a small example, how I can use ResponseEntity in this case? I have similar application where I am getting Http status code but, I could not figure out how to get Http Response body content that is sent from Remote servlet where Http outbound gateway is sending the request.

          I have following infrastructure.

          Gateway -> Router -> Transformer -> Router -> Http outbound gateway -> activator on Reply channel.

          right now, Activator has a method which take argument of type String and I am just printing it, it gives me Http status code. but remote servlet is also sending string in Response body and I need to get it back in this Activator method.


          • #6
            I'd suggest to look at the Javadoc as well as google around since there are plenty of samples out there.
            ResponseEntity is not part of SpringIntegration. It is part of new Spring 3.0 REST support and we build on top of it, so you may want to even ask a question on the different forum (perhaps web related).
            But the best advice is to look at the source code


            • #7
              Thanks oleg,

              Actually after spending some time, I found a way to get back Response body back.

              Now I have some other queries. but before that, let me explain my requirements.

              --I need to generate XML based on certain application events and then need to send it to external web application (basically some servlet there which listen my request and send back xml response to me)

              so apart from other stuff, I have Http outbound gateway which sends generated XML to my external test servlet and upon receipt of this XML, test servlet send back response XML back which I will get through reply-channel of http outbound gateway.

              my http outbound gateway defined as :

              <http:outbound-gateway id="outboundHttpGateway"

              I also have Activator defined on reply-channel to print response I get from testServlet.

              <integration:service-activator input-channel="outboundHttpReplyChannel"

              The method signature is :

              public void printoutResponse(String msg, Map headers)
              System.out.println("-------- -------- -------- --------");
              System.out.println(" The msg=" + msg);
              System.out.println(" headers=" + headers);

              I am successfully sends XML request to /test/testServlet and also successfully got the response body printed back via this method.

              Based on this I have following queries.

              1. How can I get Http status code along with http response? I need both.

              2. If you see in printoutResponse() method code, I am trying to print the Response headers, but I am getting headers of the message I passed as request through http outbound gateway to remote servlet.

              where as by looking into the code of handleRequestMessage() of, it seems that it should print HttpResponse headers. so bit confused here.


              • #8
                Can anybody please share thoughts on my previous post?