Good explanation, Mark. That makes a lot of sense.
Thanks,
Bob
Hi Mark,
I do have one question actually - is it possible to achieve a syncronous reply to the incoming request?
Yes, the request/response will appear as normal to the client. The gateway handles request/reply over Spring Integration channels (typically with an anonymous reply channel), and the ultimate response Message will be sent to the client in the HTTP response.
Perhaps you are asking a slightly different question though. If so, can you describe your use-case in general terms?
Mark Fisher
Spring Integration Lead
SpringSource, a division of VMware
http://www.springsource.com
http://www.springsource.org/spring-integration
http://blog.springsource.com/main/author/markf
My use case is to receive a message via a webservice endpoint that contains users and their addresses. Each user must be validated and if passes then saved to a database, any users who fail validtion should be sent back in the response. But during the validate and save, any valid user who's postcode has changed since the last update needs to be added to a new message which gets persisted to the database for later processing. Hope that makes sense. So in essence the validate and save is handled sync and another message is born to deal with the changed post codes async.
In an attempt to do a POC for this i have a SimpleWebServiceInboundGateway to receive the inbound message which puts the message on a direct channel which has an outbound-channel-adapter. The outbound-channel-adapter invokes a method that performs the validation and save, then creates and persists the new message but i believe is incapable of returning a reply of invalid users? Methods invoked by an
outbound-channel-adapter must return void?
Since your previous response and after looking at the code this is obviously not a problem with SimpleWebServiceInboundGateway as this class clearly is capable of dealing with replies but I cant seem to think of an elegant way round it. I guess I could use a service-activator instead but it doesnt seem to fit with the rest of my config, I already have a strategy for dealing with persisting messages using outbound-channel-adapter. I think i've been starring at the problem for too long and all will become clear after the weekend but any help is greatly appreciated and probably worth a beer at SpringOne![]()
Last edited by rhart; Feb 27th, 2009 at 05:39 PM.
I was going to suggest Service Activator until I read that you didn't think that fit your use-case. What is it that you do return in the reply? I guess it is just a fixed response?
Mark Fisher
Spring Integration Lead
SpringSource, a division of VMware
http://www.springsource.com
http://www.springsource.org/spring-integration
http://blog.springsource.com/main/author/markf
The response is dynamic. I think my problem with service activator was I didnt want it responsible for persisting the message. What I have now is a service activator dealing with the validation and save of users, creating and returning the response and putting a new message on a channel that links it to my outbound-channel-adapter for persisting the message. Sorted!
Do you have any idea when 1.0.2 will be released?
Mark Fisher
Spring Integration Lead
SpringSource, a division of VMware
http://www.springsource.com
http://www.springsource.org/spring-integration
http://blog.springsource.com/main/author/markf
Mark,
I am implementing an example using the SimpleWebServiceInboundGateway. I've been able to receive messages on the web service endpoint, but I'm confused as to how to send a response to the client (referring to your comment below, it looks like the response can be easily set up). Can you help me out?
Many Thanks,
Bob
My configuration thus far:
Code:<bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping"> <property name="mappings"> <value> {http\://www.cubrc.org/spring-ws-endpoint/schemas}TestRequest=simpleEndpoint </value> </property> </bean> <bean id="simpleEndpoint" class="org.springframework.integration.ws.SimpleWebServiceInboundGateway"> <property name="requestChannel" ref="wsRequestsChannel"/> </bean> <int:channel id="wsRequestsChannel"/> <!-- Consumer for the alert message handler --> <bean id="incomingWsConsumer" class="org.springframework.integration.endpoint.EventDrivenConsumer"> <constructor-arg ref="wsRequestsChannel"/> <constructor-arg ref="wsMessageHandler"/> </bean> <bean id="wsMessageHandler" class="org.cubrc.examples.WsMessageHandler"/> </beans>
The problem is that your endpoint is incapable of sending a reply, the MessageHandler interface has one method handleMessage who's return type is void
I used a service activator instead and returned a message from it.Code:package org.springframework.integration.message; import org.springframework.integration.core.Message; /** * Base interface for any component that handles Messages. * * @author Mark Fisher */ public interface MessageHandler { void handleMessage(Message<?> message); }