Announcement Announcement Module
No announcement yet.
How to set up a simple http web service? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set up a simple http web service?

    Hi, I'm new to Spring-Integration and I'm making a small proof of concept (POC) application for testing purposes.

    All I want the POC to do is set up a small web service, preferably rest, that simply receives a request parameter and then calls a Spring service and returns the result as a list of json. I know that Spring-Integration isn't needed for this simple example alone, but it's just a POC to get me started.

    I've startet to look at the reference documentation, and as far as I understood I need to set up a servlet and map my http:inbound gateway to it. This's what I've got so far:

    <integration:channel id="whiteSearchRequest"/>
    <integration:channel id="whiteSearchResponse"/>

    <!-- Same id as servlet name -->
    <http:inbound-gateway id="whiteSearchInboundGateway" request-channel="whiteSearchRequest" reply-channel="whiteSearchResponse" />

    <http:inbound-channel-adapter id="whiteSearchResponseAdapter" channel="whiteSearchResponse" supported-methods="GET"/>

    <!-- Call my service with the request param, and somehow convert it's content to json and send it as response. -->
    <integration:service-activator ref="whiteSearchService" method="search" input-channel="whiteSearchResponse"/>
    I just don't understand how to get the http:inbound-gateway to work correctly with the adapter and my service. There're no real good examples in the reference documentation afaik. Is it possible to also set up this using annotations?

    Currently if I call my web service I just get a "MessageDeliveryException: Dispatcher has no subscribers.":

    Any help is much appreciated!
    Last edited by pompiuses; Jan 15th, 2010, 10:55 AM.

  • #2
    "MessageDeliveryException: Dispatcher has no subscribers." means Spring Integration is sending a message to a channel at least. Good news I'd say!

    Shouldn't the whiteSearchService have an input and output? (i.e. who's taking messages from "whiteSearchRequest")?

    It might make sense to turn on SI debug loggin so you can see messages going through the system.


    • #3
      Got it working by configuring like this:
      <bean id="whiteSearchInboundRequestMapper" class="my.domain.WhiteSearchInboundRequestMapper"/>
      <bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
      <integration:channel id="whiteSearchRequest"/>
      <bean id="whiteSearchInboundGateway" class="org.springframework.integration.http.HttpInboundEndpoint">
      	<property name="requestChannel" ref="whiteSearchRequest" />
      	<property name="view" ref="jsonView" />
      	<property name="supportedMethods" >
      	<property name="expectReply" value="true" />
      	<property name="requestMapper" ref="whiteSearchInboundRequestMapper" />
      <integration:service-activator ref="whiteSearchService" method="search" input-channel="whiteSearchRequest"/>
      I couldn't figure out how to configure "whiteSearchInboundGateway" using the http:inbound-channel-adapter name space as it seems to lack a "expectReply" property, so I configured it as a bean instead.

      I've been using Spring for many years, and recently I've started looking into different ESBs. I find it very difficult to simply wrap my head around the mindset you have to have when using an ESB (channels, adapters, endpoints, transformers, aggregators etc etc). I find it very different from say the Spring MVC mindset.

      So for the future I hope the Spring Integration guys will provide users with lots more good working examples. Or else the barrier for getting started may be very high for many people, myself included. IMO i.e. Mule falls short here as it's very difficult to find good working examples although the overall documentation is good.

      I also hope that Spring Integration in the near future can support RESTful web services (jax-rs) using annotations. Currently I have to define a HttpInboundEndpoint-bean + a servlet mapping for every endpoint, which is tideous to say the least.
      Last edited by pompiuses; Jan 17th, 2010, 08:24 AM.