Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

A Brief Description of the Spring Web Service and the Contract

The web service used in this article is described in detail on the Spring website. So, I won't go into too much explanation here except to say that it's an application for booking annual leave in a company. Each booking consists of the following information:

  • Start date
  • End date
  • Person (employee)

A request is sent to the web service containing the above info. If all is in order, the web service processes the request.

The Spring web services approach is contract-first. Let's take a quick look at the contract (see Listing 2).

Listing 2 The WSDL file contract for the web service.

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:import namespace="http://mycompany.com/hr/schemas"
  <wsdl:message name="HolidayRequest">
    <wsdl:part element="schema:HolidayRequest" name="HolidayRequest"/>
  <wsdl:portType name="HumanResource">
    <wsdl:operation name="Holiday">
      <wsdl:input message="tns:HolidayRequest" name="HolidayRequest"/>
  <wsdl:binding name="HumanResourceBinding" type="tns:HumanResource">
    <soap:binding style="document"
    <wsdl:operation name="Holiday">
      <soap:operation soapAction="http://mycompany.com/RequestHoliday"/>
      <wsdl:input name="HolidayRequest">
        <soap:body use="literal"/>
  <wsdl:service name="HumanResourceService">
    <wsdl:port binding="tns:HumanResourceBinding" name="HumanResourcePort">
      <soap:address location="http://localhost:8080/holidayService/"/>

Web services development seems very complex at first. However, try to keep the basics in mind as you look at Listing 2. This WSDL file simply documents the web service contract; broken down, it consists of the following main elements:

  • Schema location
  • Web service description
  • Request type

The WSDL is described in detail on the Spring website, so I won't duplicate the details here. Let's get the service up and running on Tomcat.

  • + Share This
  • 🔖 Save To Your Account