Java Reference
In-Depth Information
Setting Up a Maven 2 Service and Client Project
Problem
You want to create a project to house a web service and its client in Maven 2. You already
understand Maven, but you aren't sure what plug-ins you need, what goals to associate them
with, or how to structure it.
Solution
Create three projects: one for the service, one for the client, and a parent. Run unit tests in the
service and client projects. Also, there are some general dependencies you'll want to set up to
work with Java EE 5, and you'll need to update the default Java SDK to 1.6.
Discussion
For the examples in this topic that use Java SE 6, you'll need to update your POM to include
the compiler plug-in that uses SE 6, as shown below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
...
This ensures that the JAX-WS and XML libraries you'll need will be available.
In general, the easiest way to create web services is to use Maven 2, set up a web project
(specify <packaging>war</packaging> ), and then create a POJO that has the @WebService
annotation on the class. If you stop there, however, your WAR will deploy properly but won't
contain any web services. That's because by default Maven 2 uses an older DTD for Servlet
2.3 in the web.xmlfile. To solve this, add the following dependency to your pom.xml:
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
Search WWH ::




Custom Search