Results 1 to 7 of 7

Thread: Http gateway example

  1. #1
    Join Date
    Jan 2011
    Posts
    4

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

    Default

    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.

  3. #3
    Join Date
    Jan 2011
    Posts
    4

    Default

    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 ?

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

    Default

    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.

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

    Default

    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

  6. #6
    Join Date
    Jan 2011
    Posts
    4

    Default

    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)

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

    Default

    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.

Posting Permissions

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