4. Creating a Contract-First JAX-WS Web service (SOAP)

PROBLEM

When designing a system that consists of multiple applications communicating with each other using web services, it is common to use contract-first development as way of defining the messages that will be handled between systems. This includes identifying the operations themselves, including the input and output parameters. This is cummulatively referred to as the contract, and it's defined as a WSDL document. When it comes time to build the systems, the applications must produce services according the predefined contract.

SOLUTION

Skyway Builder Web Services Edition can be used to implement a web service contract. Skyway Builder would discover the WSDL for the purposes of implementing the service. This is of course different than discovering the web services for the purposed of consuming the services as described in the Consume Web Services.

HOW IT WORKS

There are four steps to contract-first JAX-WS service development.

Steps for creating a contract-first JAX-WS service:

  1. Define the contract using WSDL (beyond the scope of this recipe)

  2. Import the WSDL. Upon completion of the import process, Skyway Builder will have generated Spring DSL artifacts corresponding to the imported WSDL.

  3. implement the Spring DSL services (see service implementation options)

  4. Publish the service as a JAX-WS service.

The second step is the only step that is unique to contract-first development. The following table shows the correlation between WSDL components and Spring DSL artifacts.

Table 3.1. Web Service WSDL to Skyway Mappings

WSDL ComponentSpring DSL ArtifactDescription
WSDL DocumentService

The entire WSDL document represents a Service, and a Skyway Service will be created to represent the imported service.

WSDL Complex TypesDomain Objects

Skyway domain objects will be automatically created for any complex types defined in the WSDL that are needed to interact with the service.

WSDL OperationsOperations

A Skyway operation will automatically be created for each operation defined in the WSDL. These operations are what a Skyway Builder application will use to invoke the functionality of the service.


Here are the steps for importing a WSDL.

Steps for importing a WSDL:

  1. Open the Project editor and click on the Import Web Service under Activities.

  2. From the Import WSDL Document wizard, specify the Model Package that should be used as the Target Package. The Spring DSL artifacts derived from the WSDL will be created in the selected package.

  3. Specify the location of the WSDL (WSDL Location) that contains the specifications (contract) of the services and operations that need to be implemented. You can specify the WSDL URL or select the WSDL from the file system.

  4. Click Finish.

RELATED RECIPES

  1. Publishing a JAX-WS Web service (SOAP)

  2. Consuming a SOAP Web service

  3. Consuming a REST Web Service