Spring WS - Static WSDL

In the previous chapter Spring -WS - First Application, we have generated WSDL automatically using the Spring WS Configuration. In this case, we will display how to expose the existing WSDL using the Spring WS.

Step Description
1 Create a project with a name leaveService under a package com.tutorialspoint as explained in the Spring WS - First Application chapter.
2 Create a WSDL leave.wsdl under the /WEB-INF/wsdl sub-folder.
3 Update spring-ws-servlet.xml under the /WEB-INF sub-folder. We are using the static-wsdl tag here instead of the dynamic-wsdl.
4 The final step is to create content of all source and configuration files and export the application as explained below.


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


<beans xmlns = "http://www.springframework.org/schema/beans"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context = "http://www.springframework.org/schema/context"
   xmlns:sws = "http://www.springframework.org/schema/web-services"
   xsi:schemaLocation = "http://www.springframework.org/schema/beans

   <context:component-scan base-package = "com.tutorialspoint.hr"/>
   <sws:static-wsdl id = "leave" location = "/WEB-INF/wsdl/leave.wsdl"/>

Run the Project

Once we are done with creating source and configuration files, we should export the application. Right click on the application, use Export → WAR File option and save your leaveService.war file in Tomcat's webapps folder.

Now, start the Tomcat server and ensure that we can access other webpages from the webapps folder using a standard browser. Try to access the URL – http://localhost:8080/leaveService/leave.wsdl, if everything is ok with the Spring Web Application, we will see the following screen.

Static WSDL result