Java

SOAP webservices with Maven, Introduction

Soap Webservices have been around for a while now. A Soap webservice consists of two parts; the WSDL which is basically the contract describing the interface, and the Endpoint which is the class where the call eventually ends up.

In Java there are a few ways of setting up a Soap webservice. You could write the WSDL and generate the server code from there. Writing WSDL documents by hand is a pain though and should be avoided if at all possible.

Through this tutorial, I would like to explain a cleaner method with the help of XSD files and Maven. Using XSD and Maven to create a SoapWebservice follows a few steps:

  1. Create the XSDs, these descibe the data objects in the webservice
  2. Setup Maven to generate the Java data objects
  3. Run Maven to actually create the Java data objects
  4. Write the Webservice endpoint class
  5. Deploy the application to a webserver
  6. Call the webservice to have the webservice create the WSDL for you

You could also have Maven create the WSDL for you. This would be usefull if you also need to create the Client side of the Soap service.

This tutorial will lead you through the setup of a maven project. This maven project will then be used to build up a Contract-First webservice. Eventually restrictions will be added and enforced and you will learn how to add inheritance to the generated classes.

This tutorial continuous in the next part of the series, SOAP webservices with Maven, Project Setup