Generate jax-ws server and client with maven

For running this example follow these requirements:

  • Jdk: 6 or later
  • Tomcat: ~7

Generate web service implementation

First off, create a maven project with ArchetypeArtifactId = maven-archetype-webapp

Once your maven web project is created, edit pom.xml and add the following lines:

Now let’s create your web service implementation.

Create a class and write as follow:

Edit web.xml and add servlet information:

In the same folder WEB-INF add a file called sun-jaxws.xml and put this:

Your web service is ready to be built and deployed.

Run maven clean install and deploy the generated .war file from target folder into tomcat server.

Trying this address


should display the wsdl structure.

Generate Web Service Client

Create a simple default project

Edit pom.xml and add the following lines:

Then run maven clean install to generate the client files into target/generated-sources folder.

Please notice:

In order to import wsdl from local file instead of remote url, edit pom.xml in this way:

To access local files, following lines are required


Next create file and put this code:

Running this code should write “Hello Fabrizio Starred” on the output.

Be the first to comment

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see