- Web Services: A New Paradigm in Enterprise Computing?
- Downloading the Required Files
- Introducing Maven
- A Brief Description of the Spring Web Service and the Contract
- Deploying the Web Service on Tomcat
- Running the Spring Web Services Application
- Using SOAPUI
- Conclusion
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/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:schema="http://mycompany.com/hr/schemas" xmlns:tns="http://mycompany.com/hr/definitions" targetNamespace="http://mycompany.com/hr/definitions"> <wsdl:types> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:import namespace="http://mycompany.com/hr/schemas" schemaLocation="hr.xsd"/> </xsd:schema> </wsdl:types> <wsdl:message name="HolidayRequest"> <wsdl:part element="schema:HolidayRequest" name="HolidayRequest"/> </wsdl:message> <wsdl:portType name="HumanResource"> <wsdl:operation name="Holiday"> <wsdl:input message="tns:HolidayRequest" name="HolidayRequest"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HumanResourceBinding" type="tns:HumanResource"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="Holiday"> <soap:operation soapAction="http://mycompany.com/RequestHoliday"/> <wsdl:input name="HolidayRequest"> <soap:body use="literal"/> </wsdl:input> </wsdl:operation> </wsdl:binding> <wsdl:service name="HumanResourceService"> <wsdl:port binding="tns:HumanResourceBinding" name="HumanResourcePort"> <soap:address location="http://localhost:8080/holidayService/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
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.