Skip to main content

Spring support in JAX-WS RI

Posted by kohsuke on January 4, 2007 at 11:47 AM PST

Various people have been asking us to do a better job at Spring integration. So I've been working on it, and the first cut is ready.

The idea behind this is relatively simple. Spring is widely used to configure server applications nowadays. It makes it easy to have your object reference your other objects. Thus when you are using Spring in your application, you usually want your web service implementation classes to be configured by Spring, because those classes need access to other objects in your application. The same goes to handlers, if you have any.

With the Spring support extension in the JAX-WS RI, you can now wire your service implementation classes as well as handlers by using Spring, like this:

<br /><?xml version="1.0" encoding="UTF-8"?><br /><beans xmlns=""<br />       xmlns:ws= ""<br />       xmlns:wss="" ...><br /><br />  <wss:bindings id="jax-ws.http"><br />    <wss:bindings><br />      <wss:binding url="/stockQuote"><br />        <wss:service><cs_comment  nested bean is of course fine --><br />          <ws:service impl="foo.MyService"><br />            <ws:handlers><br />              <ref bean="myHandler" /><br />            </ws:handlers><br />          </ws:service><br />        </wss:service><br />      </wss:binding><br />    </wss:bindings><br />  </wss:bindings><br /><br />  <bean id="myHandler" class="foo.MyHandler" /><br /></beans><br />

This example configures one service MyService with one handler MyHandler, then expose it to /stockQuote. Those two user classes are now wired by Spring, so you can have other dependencies injected to them in the same way you'd configure other beans in Spring.

Not only that, this extension allows you to configure JAX-WS itself from Spring. For example, by writing you can make this service SOAP 1.2 service. Or to enable addressing, you can do:

<br /><ws:service impl="foo.MyService"><br />  <ws:features><br />    <ws:addressing /><br />  </ws:features><br /></ws:service><br />

So as you can see, this can effectively replace sun-jaxws.xml. Since Spring support is open-ended, this can be used to enable other JAX-WS extensions. So for example we can use this to configure JMS transport, or to configure JSON encoding, etc.

This is still a work in progress, but since I'm new to Spring, I thought I'd make this available sooner so that people with more Spring experience can give me feedback.

If you're interested in using this (and I hope you are!), all the necessary jar files are available at maven2 repository. A sample application is available at here, and the project website is available here.


What's the status of this project ? Sample application link ...

What's the status of this project ? Sample application link does not contain the sample. Also the Project page says "status: POC" . Where can I download the jars ( I cannot use maven at this point ) ?

Thanks you.