What is this?

When your application uses Spring for wiring your code, you'll find it more convenient to use the same Spring for configuring JAX-WS. For example, that would allow your service implementations to receive resource injection via Spring, AOP stuff, logging, etc, etc. This RI extension provides this functionality.

This Spring extension also allows you to configure various aspects of your web service through Spring, such as the use of MTOM, handlers, custom transports, encoding, etc., etc.

Another purpose of this extension is to provide a general purpose mechanism that JAX-WS extension authors can use, to let users use their extensions. For example, when you write a custom transport, custom codec, or custom pipeline assembler, you can use Spring to allow users to configure your extensions.

This deployment mechanism supercedes sun-jaxws.xml and JSR-109 deployment.

Changes / Release Notes

The list of changes can be found in the release notes.

License

Distributed under dual license consisting of the CDDL v1.0 and GPL v2

Quick Start

Let's consider the most typical case, where you develop a web application and you want to deploy JAX-WS services. First your web.xml needs to have a JAX-WS servlet registered.

<web-app>
  <!-- this is for Spring -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!-- these are for JAX-WS -->
  <servlet>
    <servlet-name>jaxws-servlet</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>jaxws-servlet</servlet-name>
    <url-pattern>/add</url-pattern>
  </servlet-mapping>
  ... if you deploy more services,
  you might need more <servlet-mapping>s ...
</web-app>

Then you'd be writing something like this in your /WEB-INF/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ws="http://jax-ws.dev.java.net/spring/core"
  xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://jax-ws.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd">

  <wss:binding url="/add" service="#addService" />
  <wss:binding url="/sub">
    <wss:service><!-- nested bean is of course fine -->
      <ws:service bean="#myService" />
    </wss:service>
  </wss:binding>

  <!-- this bean implements web service methods -->
  <bean id="myService" class="foo.MyService" />

  <!-- simplest definition only needs the class name -->
  <ws:service id="addService" impl="foo.MyAddService" handlers="#myHandler"/>

  <bean id="myHandler" class="foo.MyHandler" />

</beans>

The two wss:binding definitions define what services are exposed to which part of the URL space. In the above code, it deploys two services on two URLs, and one with a handler.

If you know Spring, you should know the "rest", like how to configure your own service beans.

Sample Project

A complete sample application is also available.


Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150626.29986a4)
 
 
Close
loading
Please Confirm
Close