Announcement Announcement Module
Collapse
No announcement yet.
Http gateway example Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Http gateway example

    Hello,
    Could anybody show me an example usin SI for the following case:
    - app. is listen to http request;
    -- a request comes in REST style;
    - app. respond back ;
    -- a response contains the data in JSON format.
    Appreciate you help

  • #2
    Have you looked at Spring Integration samples?
    You can get more info here: http://blog.springsource.com/2010/09...ation-samples/

    There is a sample called multipart-http which is very close to what you are looking for.

    Comment


    • #3
      Of cause, I did, especially on multipart-http.

      The example uses inbound channel adapter. Is it possible to implement the same by HttpRequestHandlingMessagingGateway
      or HttpRequestHandlingController ?

      Comment


      • #4
        All I am saying is substitute adapters with gateways. Have you tried it?
        I'll make an additional example for it, but you don't have to wait. Just give it a shot.

        Comment


        • #5
          I just posted a new sample which is a simple echo service which uses both inbound and outbound HTTP gateways
          http://git.springsource.org/spring-i...ter/basic/http

          Let me know if that helps

          Comment


          • #6
            I did not found org.springframework.integration.samples.http.DemoH ttpClient
            Than I ran the sample via mvn jetty:run, made the call via browser and got following. Looks like it works (more or less) but how to set correct properties in the request (Content-Type: charset=UTF-8)?

            Code:
            Problem accessing /http/receiveGateway. Reason:
            
                *
            
            Caused by:
            
            java.nio.charset.IllegalCharsetNameException: *
            	at java.nio.charset.Charset.checkName(Unknown Source)
            	at java.nio.charset.Charset.lookup2(Unknown Source)
            	at java.nio.charset.Charset.lookup(Unknown Source)
            	at java.nio.charset.Charset.forName(Unknown Source)
            	at org.springframework.http.HttpHeaders.getAcceptCharset(HttpHeaders.java:184)
            	at org.springframework.integration.http.support.DefaultHttpHeaderMapper.getHttpHeader(DefaultHttpHeaderMapper.java:665)
            	at org.springframework.integration.http.support.DefaultHttpHeaderMapper.toHeaders(DefaultHttpHeaderMapper.java:292)
            	at org.springframework.integration.http.support.DefaultHttpHeaderMapper.toHeaders(DefaultHttpHeaderMapper.java:50)
            	at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:260)
            	at org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:91)
            	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
            	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
            	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
            	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
            	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
            	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
            	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
            	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
            	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
            	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
            	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
            	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
            	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
            	at org.mortbay.jetty.Server.handle(Server.java:326)
            	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
            	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
            	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
            	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
            	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
            	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
            	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

            Comment


            • #7
              Sorry its org.springframework.integration.samples.http.HttpC lientDemo. I just fixed the readme.
              And no, it will not work from the browser. You must invoke it through the client which is HTTP Outboud Gateway.

              Comment

              Working...
              X