I am building a very simple spike for http:outbound-gateway.
My app is configured as follows:
The interface is:Code:<si:gateway id="httpGateway" service-interface="bob.Gateway" default-reply-channel="httpGatewayReply" default-request-channel="httpGatewayRequest"/> <si:channel id="httpGatewayReply"/> <si:channel id="httpGatewayRequest"/> <si-http:outbound-gateway url="http://localhost:8080/Grails/test/index" request-channel="httpGatewayRequest" http-method="POST" request-timeout="2000" reply-channel="httpGatewayReply" expected-response-type="java.lang.String" auto-startup="true" charset="UTF-8" />
The test app is:Code:package bob public interface Gateway { String calculateShippingCost(Map s) }
When I run this I get the following (excerpted) stack trace:Code:package bob import org.springframework.context.support.ClassPathXmlApplicationContext; public class SIHttpTest { public static void main(String[] args) { def config = new ClassPathXmlApplicationContext("spring-config.xml"); def gateway = (Gateway)config.getBean('httpGateway') println "Calling Gateway stuff..." println gateway.calculateShippingCost([fromLoc: "Brisbane", toLoc: 'Darwin', nItems: 1]) println "Done." } }
All is OK if I alter to test app to remove the integer map entry, thus:Code:org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/Grails/test/index] at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:243) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:98) ... Caused by: org.springframework.http.converter.HttpMessageNotWritableException: Could not write request: no suitable HttpMessageConverter found for request type [java.lang.Integer] at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:292) ... Exception in thread "main" org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/Grails/test/index] at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:243) ... Caused by: org.springframework.http.converter.HttpMessageNotWritableException: Could not write request: no suitable HttpMessageConverter found for request type [java.lang.Integer] at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:292) at ...
It's also OK if I treat nItems as a string:Code:println gateway.calculateShippingCost([fromLoc: "Brisbane", toLoc: 'Darwin'])
This is surprising to me.Code:println gateway.calculateShippingCost([fromLoc: "Brisbane", toLoc: 'Darwin', nItems: '1'])
Do I need to create a converter for Integer?
Thoughts/guidance/suggestions gratefully accepted.
Cheers,
Alph


Reply With Quote