Announcement Announcement Module
Collapse
No announcement yet.
Inbound HTTP Web Service adapter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inbound HTTP Web Service adapter?

    Is there an existing HTTP Web Service adapter, or a way to easily construct one with the current Spring-WS and Spring-Integration tools? We're evaluating Spring-Integration and here's two scenarios we need:
    Synchronous case:
    external HTTP Web Service client -> our HTTP Web Service Endpoint (myWS) -> JMS Request queue -> [process request] -> JMS Response Queue -> (myWS) -> return result to external HTTP client which is waiting
    Async w/callback:
    same as above, but the endpoint (myWS) does not not block, it does an ACK immediately and the result is done via pre-configured HTTP WS callback

    This is the normal sync-to-async problem, and NO, we can't just tell the client to just send us a JMS message

  • #2
    Originally posted by prpatel View Post
    This is the normal sync-to-async problem, and NO, we can't just tell the client to just send us a JMS message
    Yes it would be nice if you could just tell your clients to solve their own @#$ problems . So that's what I'm going to do:

    You could use a gateway or MessageChannelTemplate to solve the sync async problem. We have a generic solution for this in the framework and there is no reason you couldn't use that inside a ws implementation.

    There is in fact an issue open for this in our JIRA: http://jira.springframework.org/browse/INT-162. However it's planned for 1.2, so you'll have to use your own implementation for now.

    If you have comments or ideas it would be great if you can give your input on the JIRA issue so we don't make something you don't like later.

    Comment


    • #3
      The initial support for inbound WS is now available. We have the following two classes:
      SimpleWebServiceInboundGateway
      MarshallingWebServiceInboundGateway

      These are available in the nightly build (and will be released with version 1.0.2). You can get the very latest version by checking out the SVN trunk or download the nightly snapshot here (or any later nightly by changing the build number):
      https://build.springframework.org/do...-424/artifacts

      These gateways are themselves Spring-WS Endpoint implementations. Therefore to use them, simply register the Spring-WS MessageDispatcherServlet in web.xml:
      Code:
        <servlet>
        	<servlet-name>ws</servlet-name>
        	<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
        </servlet>
        
        <servlet-mapping>
        	<servlet-name>ws</servlet-name>
        	<url-pattern>/ws/*</url-pattern>
        </servlet-mapping>
      Then, any Spring-WS EndpointMapping can be used. For example:
      Code:
      <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
          <property name="mappings">
              <value>
                  foo=simpleEndpoint
                  bar=marshallingEndpoint
              </value>
          </property>
      </bean>
      (With the configuration above any XML with a "foo" root element name will go to the simple endpoint while any XML with a "bar" root element name will go to the marshalling endpoint.)

      Then, add the Spring Integration gateway(s):
      Code:
      <bean id="simpleEndpoint" class="org.springframework.integration.ws.SimpleWebServiceInboundGateway">
          <property name="requestChannel" ref="wsRequests"/>
      </bean>
      
      <bean id="marshallingEndpoint" class="org.springframework.integration.ws.MarshallingWebServiceInboundGateway">
          <property name="requestChannel" ref="wsRequests"/>
          <property name="marshaller" ref="someMarshaller"/>
          <property name="unmarshaller" ref="someMarshaller"/>
      </bean>
      If you get a chance to try this out, please provide feedback so that we can take any suggestions into account for the 1.0.2 release.

      Thanks,
      Mark

      Comment


      • #4
        Please note that when using WS-Addressing soap headers, the endpoint mapping type should be SimpleActionEndpointMapping as described in the Spring Web Services reference manual here: http://static.springsource.org/sprin...-ws-addressing

        Comment


        • #5
          Brilliant! I've been waiting for this

          One idea I had though was instead of having an endpoint that routes to a channel having an endpoint mapper that would, something like this

          Code:
          <bean class="org.springframework.ws.server.endpoint.mapping.ChannelRoutingEndpointMapping">
              <property name="mappings">
                  <value>
                      foo=channelA
                      bar=channelB
                  </value>
              </property>
          </bean>

          Comment


          • #6
            I'm also very interested in an inbound WS adapter. I'll try it out when I get a chance and provide some feedback.

            One question: Does the implementation provide a WSDL that clients can access?

            Thanks,
            Bob

            Comment


            • #7
              Yes, the WSDL will be generated automatically if you just add a bean definition as described in the Spring Web Services reference manual here:
              http://static.springsource.org/sprin...-wsdl-exposure

              Comment


              • #8
                Originally posted by rhart View Post
                One idea I had though was instead of having an endpoint that routes to a channel having an endpoint mapper that would
                Thanks for the feedback! Let me see if I can clearly explain the rationale for the approach we have taken...

                If we implemented an EndpointMapping like that, it would first need to create actual Endpoint instances behind the scenes. Beyond that, there are a couple reasons that we decided to expose Endpoint implementations rather than something at the level of an EndpointMapping. In general, we wanted to re-use the capabilities in Spring Web Services (and to automatically take advantage of future extensions). Here are a couple of the main points:
                1. Different EndpointMappings are necessary for different strategies (payload root QName, XPath expression, SoapAction, WS-Addressing)
                2. Spring Web Services already supports interceptors for EndpointMappings, and the application of these may vary for different types of mapping (e.g. distinct pre/post-interceptors for WS-Addressing)
                3. We have 2 different inbound-gateway implementations: a payload endpoint and a marshalling endpoint
                4. We already offer a lot of XML capabilities (e.g. XPath router) that can be leveraged for more fine-grained routing, but the coarse-grained routing may rely on one of the other strategies mentioned above (e.g. Soap Action)

                Does that explanation make sense?

                Regards,
                Mark

                Comment


                • #9
                  Originally posted by Mark Fisher View Post
                  Yes, the WSDL will be generated automatically if you just add a bean definition as described in the Spring Web Services reference manual here:
                  http://static.springsource.org/sprin...-wsdl-exposure
                  Mark,

                  Thank you for the response.

                  I have one other small question: Does spring-ws support publishing of wsdls using the ?wsdl notation (as opposed to the .wsdl) notation?

                  Thanks,
                  Bob

                  Comment


                  • #10
                    Bob,

                    The reason that Spring Web Services exposes with a .wsdl extension is that the contract-first approach decouples the contract from the service (with the endpoint as the intermediary). Therefore the WSDL is a "standalone document" as opposed to something attached to a particular service instance.

                    It is explained (probably more clearly) in the Spring Web Services FAQ here:
                    http://static.springsource.org/sprin...#wsdl-retrieve

                    Comment


                    • #11
                      Originally posted by Mark Fisher View Post
                      Does that explanation make sense?
                      Yep, perfect sense. I didnt really think much outside my own little box

                      By the way, I replaced my custom code this afternoon with a SimpleWebServiceInboundGateway and it worked like a dream!

                      Comment


                      • #13
                        Hi Mark,

                        I do have one question actually - is it possible to achieve a syncronous reply to the incoming request?

                        Comment


                        • #14
                          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?

                          Comment


                          • #15
                            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, 05:39 PM.

                            Comment

                            Working...
                            X