{"id":4200,"date":"2020-07-31T17:54:41","date_gmt":"2020-07-31T12:24:41","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=4200"},"modified":"2025-12-05T05:51:05","modified_gmt":"2025-12-05T10:51:05","slug":"what-is-spring-web-service","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/what-is-spring-web-service\/","title":{"rendered":"What is Spring Web Service?"},"content":{"rendered":"\n<p>Spring Web Services (Spring-WS) developed by the spring community focuses on the creation of document-driven Web services. It facilitates the contract-first SOAP Service Development. It can manipulate XML payloads in many ways. Spring Web Services aims to give loose coupling between the WSDL contract and its JAVA based implementation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Features of Spring Web Services:<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>XML Mapping to Objects: Requests based on XML can be mapped to any object with the help of the information stored in the Message Payload, SOAP Action Header, or using an XPath Expression.<\/li>\n\n\n\n<li>Multiple API Support to parse XML: It supports from the standard JAXP APIs (DOM, SAX, StAX) to parse the incoming XML requests, it also supports other libraries like JDOM, dom4j, XOM.<\/li>\n\n\n\n<li>Multiple API Support to marshal XML: Spring Web Services supports Castor, XMLBeans, JiBX, and XStream libraries using its Object\/XML Mapping module.\u00a0<\/li>\n\n\n\n<li>Spring-based configurations: Spring Web Services also uses the <a href=\"https:\/\/www.h2kinfosys.com\/blog\/spring-aop\/\">Spring Application<\/a> Contexts for its configurations that are having a similar architecture like that of the Spring Web MVC.<\/li>\n\n\n\n<li>Integrated WS-Security module: With the help of the WS-Security module, you can Sign, Encrypt, Decrypt SOAP Messages, or Authenticate them.<\/li>\n\n\n\n<li>Support for Acegi Security: With the help of the WS-Security implementation of Spring Web Services, Acegi configuration can also be used for your SOAP services.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The architecture of Spring Web Services:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.h2kinfosys.com\/courses\/java-online-training-course-details\/\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/j8Q636Yy31iv5jRdWuITOKjJo55vceVyV2urHWz5PvfwWTS1l_JLOqnsDoRnnoxQs6gZ2Z92wC79SDz_W_wRBYfrcfdF7AQ7PdHdbySc3j2pjbu3wlez-5QDwQOCrC0_q2sUum0endl5ENBFJA\" alt=\"Spring Web Services Architecture\" title=\"\"><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Spring-WS Core: This is the primary module, and it contains the Central Interfaces like WebServiceMessage and SoapMessage, the server-side framework, powerful message dispatching capability, and also support classes to implement Web service endpoints. It also contains Web Service consumer clients as WebServiceTemplate.<\/li>\n\n\n\n<li>Spring-WS Support: This module contains supports for JMS, emails, etc.<\/li>\n\n\n\n<li>Spring-WS Security: This module contains a WS-Security implementation integrated with the core Web Service Module. Also, we can add principal tokens, sign, encrypt, and decrypt SOAP messages. It allows using the existing Spring Security Implementation for authentication and authorization.<\/li>\n\n\n\n<li>Spring XML: It contains XML support classes for Spring Web Services. It is internally used by the Spring-WS framework.<\/li>\n\n\n\n<li>Spring OXM: It contains support classes for XML vs. Object Mapping.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to create a Spring WS Application?<\/strong><\/h2>\n\n\n\n<p>Here, we are going to write a simple Spring WS Application which will book leave in an HR Portal.<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Spring-WS follows the Contract-first approach, which means that you should have your XML Structures ready before writing any JAVA based implementation code. So first, we will design the XML Constructs.<\/p>\n\n\n\n<p><strong>Leave.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Leave xmlns = \"http:\/\/example.com\/hr\/schemas\"&gt;\n&nbsp;&nbsp;&nbsp;&lt;StartDate&gt;2020-06-23&lt;\/StartDate&gt;\n&nbsp;&nbsp;&nbsp;&lt;EndDate&gt;2020-06-27&lt;\/EndDate&gt;\n&lt;\/Leave&gt;<\/pre>\n\n\n\n<p><strong>Employee.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Employee xmlns = \"http:\/\/example.com\/hr\/schemas\u201d&gt;\n&nbsp;&nbsp;&nbsp;&lt;Number&gt;404&lt;\/Number&gt;\n&nbsp;&nbsp;&nbsp;&lt;FirstName&gt;Mahesh&lt;\/FirstName&gt;\n&nbsp;&nbsp;&nbsp;&lt;LastName&gt;Parashar&lt;\/LastName&gt;\n&lt;\/Employee&gt;<\/pre>\n\n\n\n<p><strong>LeaveResquest.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Employee xmlns = \"http:\/\/example.com\/hr\/schemas\u201d&gt;\n&lt;Leave&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;StartDate&gt;2020-07-03&lt;\/StartDate&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;EndDate&gt;2020-07-07&lt;\/EndDate&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/Leave&gt;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;Employee&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Number&gt;404&lt;\/Number&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;FirstName&gt;Mahesh&lt;\/FirstName&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;LastName&gt;Parashar&lt;\/LastName&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/Employee&gt;\n&lt;\/LeaveRequest&gt;<\/pre>\n\n\n\n<p><strong>hr.xsd\u00a0<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;xs:schema xmlns:xs = \"https:\/\/www.w3.org\/2001\/XMLSchema\"\n&nbsp;&nbsp;&nbsp;xmlns:hr = \"https:\/\/example.com\/hr\/schemas\"\n&nbsp;&nbsp;&nbsp;elementFormDefault = \"qualified\"\n&nbsp;&nbsp;&nbsp;targetNamespace = \"https:\/\/example.com\/hr\/schemas\"&gt;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"LeaveRequest\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:all&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Leave\" type = \"hr:LeaveType\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Employee\" type = \"hr:EmployeeType\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:all&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:element&gt;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;xs:complexType name = \"LeaveType\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"StartDate\" type = \"xs:date\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"EndDate\" type = \"xs:date\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;xs:complexType name = \"EmployeeType\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Number\" type = \"xs:integer\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"FirstName\" type = \"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"LastName\" type = \"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&lt;\/xs:schema&gt;<\/pre>\n\n\n\n<p><strong>Step 2: <\/strong>Open the command console. Go to the C:\/MVN directory and execute the below command.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/LOAHgEs98wZ-zwlMBFA2qZjuttI9U9rQyPc0TlgPXOgIoDC03PViifDUCrrrHZX3cHKSrDE54dMZT42AKeGwhTMqWllfpkHGs4jviAGjF7Vylw9FpaoBtFdT1sSkGYOKLAnWd4KRx9XAr-bmHg\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 3: <\/strong>Spring Web Services go to the directory C:\/MVN and you will see a project named leaveService. Update the pom.xml file and add HumanResourceService.java and HumanResourceServiceImpl.java in:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/SkFdB2ddU_i2b26_fBI9fAqgnpmgBlR_zuzkNIhPCXr4WusNQ7UMIv2R9frV9MWLho1CAAE9K6XlMw5YJn0wD8c3a-Hx2GJaWK3igmE6gxVCUv0IWI_4YH5MKrBe14EU2ad8uDH3clYEQa_KIQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Then open the folder&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/v6StZBCsGkWKsumYWg1ewD3PgxCNeBqFyN2bzDDqu7hYVhusqrWFMaLgulhVFz6om6d2ik0Vj1iDgWKxOKFc626yxiZAKAojk3QRmZF1_I75L9jL-VXup-6Fe6uPXOh_p93Up1VYmWDMiwoCwA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>pom.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version = \"1.0\" encoding = \"UTF-8\"?&gt;\n&lt;project xmlns = \"http:\/\/maven.apache.org\/POM\/4.0.0\"\n&nbsp;&nbsp;&nbsp;xmlns:xsi = \"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n&nbsp;&nbsp;&nbsp;xsi:schemaLocation = \"http:\/\/maven.apache.org\/POM\/4.0.0\n&nbsp;&nbsp;&nbsp;http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n&nbsp;&nbsp;&nbsp;&lt;groupId&gt;com.example.hr&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;leaveService&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&lt;packaging&gt;war&lt;\/packaging&gt;\n&nbsp;&nbsp;&nbsp;&lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&lt;name&gt;leaveService Spring-WS Application&lt;\/name&gt;\n&nbsp;&nbsp;&nbsp;&lt;url&gt;http:\/\/www.springframework.org\/spring-ws&lt;\/url&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;build&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;finalName&gt;leaveService&lt;\/finalName&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/build&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;dependencies&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.springframework.ws&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;spring-ws-core&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;2.4.0.RELEASE&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;jdom&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;jdom&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.0&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;jaxen&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;jaxen&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.1&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;wsdl4j&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;wsdl4j&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.6.2&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/dependencies&gt;\n&lt;\/project&gt;<\/pre>\n\n\n\n<p><strong>HumanResourceService.java<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">package com.example.hr.service;\nimport java.util.Date;\npublic interface HumanResourceService {\n&nbsp;&nbsp;&nbsp;void bookLeave(Date startDate, Date endDate, String name);\n}<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">package com.example.hr.service;\nimport java.util.Date;\nimport org.springframework.stereotype.Service;\n@Service\npublic class HumanResourceServiceImpl implements HumanResourceService {\n&nbsp;&nbsp;&nbsp;public void bookLeave(Date startDate, Date endDate, String name) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(\"Booking holiday for [\" + startDate + \"-\" + endDate + \"]\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for [\" + name + \"] \");\n&nbsp;&nbsp;&nbsp;}\n}\n<\/pre>\n\n\n\n<p><strong>LeaveEndPoint.java<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">package com.example.hr.ws;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.ws.server.endpoint.annotation.Endpoint;\nimport org.springframework.ws.server.endpoint.annotation.PayloadRoot;\nimport org.springframework.ws.server.endpoint.annotation.RequestPayload;\nimport com.example.hr.service.HumanResourceService;\nimport org.jdom.Element;\nimport org.jdom.JDOMException;\nimport org.jdom.Namespace;\nimport org.jdom.xpath.XPath;\n@Endpoint\npublic class LeaveEndpoint {\n&nbsp;&nbsp;&nbsp;private static final String NAMESPACE_URI = \"http:\/\/example.com\/hr\/schemas\";\n&nbsp;&nbsp;&nbsp;private XPath startDateExpression;\n&nbsp;&nbsp;&nbsp;private XPath endDateExpression;\n&nbsp;&nbsp;&nbsp;private XPath nameExpression;\n&nbsp;&nbsp;&nbsp;private HumanResourceService humanResourceService;\n&nbsp;&nbsp;&nbsp;@Autowired\n&nbsp;&nbsp;&nbsp;public LeaveEndpoint(HumanResourceService humanResourceService) throws JDOMException {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.humanResourceService = humanResourceService;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Namespace namespace = Namespace.getNamespace(\"hr\", NAMESPACE_URI);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startDateExpression = XPath.newInstance(\"\/\/hr:StartDate\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startDateExpression.addNamespace(namespace);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endDateExpression = XPath.newInstance(\"\/\/hr:EndDate\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endDateExpression.addNamespace(namespace);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameExpression = XPath.newInstance(\"concat(\/\/hr:FirstName,' ',\/\/hr:LastName)\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameExpression.addNamespace(namespace);\n&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;@PayloadRoot(namespace = NAMESPACE_URI, localPart = \"LeaveRequest\")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;public void handleLeaveRequest(@RequestPayload Element leaveRequest) throws Exception {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat dateFormat = new SimpleDateFormat(\"yyyy-MM-dd\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date startDate = dateFormat.parse(startDateExpression.valueOf(leaveRequest));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date endDate = dateFormat.parse(endDateExpression.valueOf(leaveRequest));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String name = nameExpression.valueOf(leaveRequest);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;humanResourceService.bookLeave(startDate, endDate, name);\n&nbsp;&nbsp;&nbsp;}\n}\n<\/pre>\n\n\n\n<p><strong>\/WEB_INF\/spring-ws-servlet.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns = \"http:\/\/www.springframework.org\/schema\/beans\"\n&nbsp;&nbsp;&nbsp;xmlns:xsi = \"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n&nbsp;&nbsp;&nbsp;xmlns:context = \"http:\/\/www.springframework.org\/schema\/context\"\n&nbsp;&nbsp;&nbsp;xmlns:sws = \"http:\/\/www.springframework.org\/schema\/web-services\"\n&nbsp;&nbsp;&nbsp;xsi:schemaLocation = \"http:\/\/www.springframework.org\/schema\/beans&nbsp;\n&nbsp;&nbsp;&nbsp;http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\n&nbsp;&nbsp;&nbsp;http:\/\/www.springframework.org\/schema\/web-services\n&nbsp;&nbsp;&nbsp;http:\/\/www.springframework.org\/schema\/web-services\/web-services-2.0.xsd\n&nbsp;&nbsp;&nbsp;http:\/\/www.springframework.org\/schema\/context\n&nbsp;&nbsp;&nbsp;http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\"&gt;\n&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package = \"com.example.hr\"\/&gt;\n&nbsp;&nbsp;&nbsp;&lt;bean id = \"humanResourceService\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class = \"com.example.hr.service.HumanResourceServiceImpl\" \/&gt;\n&nbsp;&nbsp;&nbsp;&lt;sws:annotation-driven\/&gt;\n&nbsp;&nbsp;&nbsp;&lt;sws:dynamic-wsdl id = \"leave\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;portTypeName = \"HumanResource\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locationUri = \"\/leaveService\/\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetNamespace = \"http:\/\/example.com\/hr\/definitions\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;sws:xsd location = \"\/WEB-INF\/hr.xsd\"\/&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/sws:dynamic-wsdl&gt;\n&lt;\/beans&gt;<\/pre>\n\n\n\n<p><strong>\/WEB_INF\/web.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;web-app xmlns = \"http:\/\/java.sun.com\/xml\/ns\/j2ee\"\n&nbsp;&nbsp;&nbsp;xmlns:xsi = \"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n&nbsp;&nbsp;&nbsp;xsi:schemaLocation = \"http:\/\/java.sun.com\/xml\/ns\/j2ee\n&nbsp;&nbsp;&nbsp;http:\/\/java.sun.com\/xml\/ns\/j2ee\/web-app_2_4.xsd\"\n&nbsp;&nbsp;&nbsp;version = \"2.4\"&gt;\n&nbsp;&nbsp;&nbsp;&lt;display-name&gt;Example HR Leave Service&lt;\/display-name&gt;\n&nbsp;&nbsp;&nbsp;&lt;servlet&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;spring-ws&lt;\/servlet-name&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-class&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.springframework.ws.transport.http.MessageDispatcherServlet\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/servlet-class&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;init-param&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-name&gt;transformWsdlLocations&lt;\/param-name&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-value&gt;true&lt;\/param-value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/init-param&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/servlet&gt;\n&nbsp;&nbsp;&nbsp;&lt;servlet-mapping&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;spring-ws&lt;\/servlet-name&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/servlet-mapping&gt;\n&lt;\/web-app&gt;<\/pre>\n\n\n\n<p><strong>\/WEB_INF\/hr.wsd<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;xs:schema xmlns:xs = \"http:\/\/www.w3.org\/2001\/XMLSchema\"\n&nbsp;&nbsp;&nbsp;xmlns:hr = \"http:\/\/example.com\/hr\/schemas\"\n&nbsp;&nbsp;&nbsp;elementFormDefault = \"qualified\"\n&nbsp;&nbsp;&nbsp;targetNamespace = \"http:\/\/example.com\/hr\/schemas\"&gt;\n&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"LeaveRequest\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:all&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Leave\" type = \"hr:LeaveType\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Employee\" type = \"hr:EmployeeType\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:all&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:element&gt;\n&nbsp;&nbsp;&nbsp;&lt;xs:complexType name = \"LeaveType\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"StartDate\" type = \"xs:date\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"EndDate\" type = \"xs:date\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&lt;xs:complexType name = \"EmployeeType\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"Number\" type = \"xs:integer\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"FirstName\" type = \"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name = \"LastName\" type = \"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&lt;\/xs:schema&gt;<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>Open the command console, and go the directory C:\\MVN\\leaveService and execute the below mvn command:<\/p>\n\n\n\n<p>C:\\MVN\\leaveService&gt;mvn clean package<\/p>\n\n\n\n<p><strong>Step 5: <\/strong>Open Eclipse IDE. Go to File &gt; Import &gt; Option. Select the option Maven Projects and click on the Next button.<\/p>\n\n\n\n<p>Select the location of the leaveService project. Click on the Finish button.<\/p>\n\n\n\n<p><strong>Step 6: <\/strong>The Spring Web Services Export the application by right-clicking on the project > Export > WAR File. Save it in the Tomcat\u2019s webapp folder. Start the Tomcat and go to the URL <span class=\"has-inline-color has-cyan-bluish-gray-color\">http:\/\/localhost:8080\/leaveService\/leave.wsdl<\/span>.\u00a0<\/p>\n\n\n\n<p>If everything works fine then you will see the below output on the screen with the document tree:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/eRu_3ujgjx68rMHPFLumbL04bx6QPZNwYNZ-KMHs69qAWlBL9vYEx7P4Ff22wRCG8rS8HiSHD3Nw3tbPn1sIrNN5aJ_tALRCQMOX52aOMUvM8BdIujWrV6uhRI1ID7eL-XcU7f6o-cNclVR4Hg\" alt=\"\" style=\"width:561px;height:30px\" title=\"\"><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Spring Web Services (Spring-WS) developed by the spring community focuses on the creation of document-driven Web services. It facilitates the contract-first SOAP Service Development. It can manipulate XML payloads in many ways. Spring Web Services aims to give loose coupling between the WSDL contract and its JAVA based implementation. Features of Spring Web Services: The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[1159,1170],"class_list":["post-4200","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-features","tag-spring-web-service"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=4200"}],"version-history":[{"count":1,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4200\/revisions"}],"predecessor-version":[{"id":32523,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4200\/revisions\/32523"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/4210"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=4200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=4200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=4200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}