Using JiBX/WS with Spring

JiBX/WS supports the configuration of web service operations using the Spring Framework.

The class WsSpringServlet is an extension of Spring's FrameworkServlet class, customized to work with JiBX/WS. By default, this class loads the application context from an XML file whose name is based on the servlet-name that is defined in the web.xml file. The suffix -servlet.xml is added to the servlet-name name to derive the application context file name.

The application context must contain a bean that implements ServiceMapper. By default, this bean must be named serviceMapper. This bean maps the incoming HTTP request to a Service instance that handles the request. Services are defined using ServiceDefinition beans. The ServiceDefinition class exposes all of the properties available to JiBX/WS Service Definitions, plus additional methods to allow object instances to be assigned for Service, ServiceExceptionHandler and OutputCompletionListener objects. It is necessary to configure init() as an init-method on the ServiceDefinition bean.

For an example, see the Spring Hello World example. This example includes 2 services showing the usage of JiBX/WS with both Singleton and Request scope beans.

[Note: It is planned to simplify the Spring configuration in a future release using a custom namespace. We also plan to introduce more ServiceMappers.]

Dependencies

In addition to the basic runtime dependencies, using Spring with JiBX/WS requires spring-webmvc.jar, spring-beans.jar, spring-core.jar, spring-context.jar and spring-web.jar. If using Request scoped beans, you will also need the spring-aop.jar and cglib.jar files. For Maven users, these dependencies are defined as optional in the pom.xml for JiBX/WS. For Ivy usage, they are defined using the configurations spring-server and spring-server-aop in the ivy.xml file.