Hi,
I am trying to expose a rest webservice using HTTP inbound gateway. I am not able to access the "retailer" path variable in the service activator.
I am using Spring 3.0.6 and Spring integration 2.0.5 RELEASE.
Please help, I tried googling but I am not able to find any suitable sample which will give me this pathvariable access.
I have created following things.
- Inbound Channel
- Outbound Channel
- Inbound Gateway
- Service Activator
Following is the configuration I have created.
WEB.xml
Code:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>businessIntegration</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>businessIntegration</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
servlet-context.xml
Code:
<bean name="auditLogGateway" class="uk.co.fresca.api.common.auditlog.AuditLogGateway"></bean>
<!-- findAll Log -->
<int:channel id="findAllLogsInboundChannel" />
<int-http:inbound-gateway request-channel="findAllLogsInboundChannel" name="/findLogs/{retailer}/{product}" mapped-request-headers="Accept-Charset:utf-8" supported-methods="GET" reply-channel="findAllLogsTransformedChannel"/>
<int:service-activator expression="@auditLogGateway.fetchAllLogs(#pathVariables.retailer)" id="findLogs" input-channel="findAllLogsInboundChannel" output-channel="findAllLogsOutboundChannel" >
</int:service-activator>
<int:channel id="findAllLogsOutboundChannel"></int:channel>
<int:object-to-json-transformer input-channel="findAllLogsOutboundChannel" output-channel="findAllLogsTransformedChannel"></int:object-to-json-transformer>
<int:channel id="findAllLogsTransformedChannel"></int:channel>
Code:
public Message<List> fetchAllLogs(String retailer){
System.out.println(retailer);
Message<List> retMessage = new GenericMessage<List>(new ArrayList());
return retMessage;
}