SyntaxHighlighter

Wednesday, July 4, 2012

Spring Integration Web Service - Inbound

Spring Integration Web Service - Inbound

after bashing my head against a brick wall on this one, i've finally got a simple example together of how to assemble a Spring Integration Web Service Inbound gateway which includes the following;
- simple POJO Service
- XSD of an object
- JAXB generated domain objects
- Spring-WS dynamic WSDL
- Spring Integration WS Endpoint and Test Client

Domain Object

let's start by putting together a domain object.  This is a really simple domain object with a couple of simple components that built from an XSD


and here's a sample xml based on that schema


now we need to generate the Java objects from this.  to do that, we can use Eclipses built-in JAXB Component "JAXB Classes from Schema"

Service

ok, so the idea is that we create a service to manage these objects.  as with all Spring Integration projects, we should focus on a separation of concerns and should be able to use the service independently of Spring Integration.


and lets create a dead simple implementation of the service


Spring

now for the wiring...

for the sake of separation, we'll create 3 different spring files
- our Spring Integration configuration (what we'll do with a message)
- our XML Parser configuration (how we'll sort out the XML piece)
- our URI and WSDL configuration

here's the integration config





and here's the parser config





and finally, the Web Service config using a Dynamic WSDL generator







Server Side



for the server part, we'll need to expose the relevant Spring Servlet via the web.xml...







Does it work?

here's the two urls you can try to verify that it works;
- open up a browser and point to http://[your server]/[your app]/issueService/
your response should be a 405 - that's ok!
- open up a browser and point to http://[your server]/[your app]/issueService/issueService.wsdl
your response should be the WSDL file to use


5 comments:

  1. Thanks for posting.. I am new to SI and doing some poc.. the configuration is pretty much the same as in my code.. but I am having issue accessing the dynamic wsdl from browser. I am able to access the service and browser returns 405 but when I access wsdl i get 404.

    ReplyDelete
  2. This is a simple but good example. I had the same issue where spring did not provide much information on creating SI based WS. I'm a newbie to spring ws but had some previous experience with SI. So your example was really helpful.

    Have a question though, how did you decide which EndpointMapping implementation to use? Does spring provide some guideline in this case?

    ReplyDelete
    Replies
    1. the UriEndpointMapping is very similar to UriPathHandlerMapping from Spring Integration hence the choice.

      Delete
  3. Hi,Website owners provide their websites files in Web Design Cochin to the web host for storage and publication on the Web. So, a web hosting is like an online home for a website.Thanks.............

    ReplyDelete
  4. Absolute GENIUS... Keep it Up.It has solved one my issues.Thank You.

    ReplyDelete