Are you sure you want Axis2?
If you just need to serve up some XML or JSON in response to some GET requests, and perhaps a bit of data create/update/delete through POST, PUT and DELETE requests then RESTEasy is a good choice. It's an implementation of JAX-RS and is trivial to get working.
Taking a RESTful approach will help your application to remain stateless (no sessions to share) which in turn will allow you to scale much more easily later. You'll be working closely with the HTTP specification and your application should be straightforward to manage at the web level.
If you can avoid all the faffing about with SOAP request envelopes and everything else then you'll be doing yourself a favour.
Simple example of JAX-RS markup
As an example, suppose you wanted to submit an XML document as a PUT request to trigger an update to your persistent store. Typically you'd have
- a web front end (
MyWebService
),
- a bit of JAXB and JPA (read Hibernate) markup on a domain object represented by the XML (call it
MyDomain
),
- some transaction markup on the service layer (
MyService
),
- a DAO to handle the update (
MyDao
)
Your web front end for this could look like this (all annotations come from JAX-RS):
@Path("/MyWebService")
public class MyWebService {
private MyService service = new MyService(); // Use injection via setters and Spring
@PUT
@Consumes("application/xml")
@Path("/UpdateMyDomain")
public Response updateMyDomain(MyDomain myDomain) {
// Do some validation then hand over
service.updateDomain(myDomain);
return Response.ok("All done").build(); // for a PUT you'd really have a Location etc
}
}
The HTTP request described below will be directed to the above method
PUT /MyWebService/UpdateMyDomain
Content-Type: application/xml
<?xml ... >
<MyDomain>
...
</MyDomain>
Your web.xml would look a bit like this
<!-- Provide Spring context -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:my-application-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<listener>
<listener-class>
org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>RESTEasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RESTEasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
There's not much else you'd need. Well, maybe the Maven dependency list would be useful (perhaps use version 1.2GA or higher):
<!-- RESTEasy JAX-RS JBoss implementation -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
<!-- RESTEasy Core library -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<!-- RESTEasy JAXB support -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</dependency>
<!-- RESTEasy multipart/form-data and multipart/mixed support -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
</dependency>
<!-- RESTEasy Spring integration -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
</dependency>
Are you sure you want Tomcat?
Perhaps the lightweight Jetty (which can be used as a Maven plugin to allow developers to run multiple applications locally) would be a better choice. If all you need is a servlet container that can provide a database connection via JNDI then Tomcat is probably overkill.