The java pet store example in the spring distribution has an example of this. There was also some talk on the spring framework mailing list not too far back about how to expose a bean as an axis web service. I however took a simpler, more clumsy approach.

I have a wrapper implementation of my service which looks something like this:

public class DelegatingMyServiceImpl implements MyService, ServiceLifecycle {

 private MyService myService;
 private ServletContext servletContext;

 public DelegatingMyServiceImpl() {

 }

private synchronized MyService getMyService() {
if (myService == null) {
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
embassyServer = (EmbassyServer) context.getBean("myServiceBean");
}


   return myService;
 }

 public void serviceMethod() throws RemoteException {
   getMyService().serviceMethod();
 }

 public void init(Object context) throws ServiceException {

   ServletEndpointContext soapContext = (ServletEndpointContext) context;
   servletContext = soapContext.getServletContext();
 }

 public void destroy() {
   myService = null;
 }
}

This is what gets registered with axis in server-config.wsdd. Note that it implements ServiceLifecycle from jax-rpc to get the servlet context.

Your myServiceBean dec in you bean factory xml will be whatever you need it to be with the corresponding dependencies. Good luck.

 --m



Marco Mistroni wrote:

Hi all,

            Has anyone tried to use Spring Framework together with Axis?

I want to write a webservice which needs to access a database, and I want to be able to do it

By using either Castor, Hibernate, plain JDBC & other OR mapping tools..



I have already a DAO interface and different implementations depending on the tech,



So rather than writing a different webservice depending on the tech used, I wanted to go

For using Spring



Has anyone ever tried Spring with Axis for webservices?



Any ideas/comments appreciated



Thanx in advance and regards

            marco

Reply via email to