├── src ├── main │ ├── resources │ │ ├── application.properties │ │ └── loaneligibility.xsd │ └── java │ │ └── com │ │ └── javatechie │ │ └── spring │ │ └── soap │ │ └── api │ │ ├── SpringBootSopaWsApplication.java │ │ ├── loaneligibility │ │ ├── package-info.java │ │ ├── ObjectFactory.java │ │ ├── Acknowledgement.java │ │ └── CustomerRequest.java │ │ ├── emdpoint │ │ └── LoanEligibilityindicatorEndpoint.java │ │ ├── service │ │ └── LoanEligibilityService.java │ │ └── config │ │ └── SoapWSConfig.java └── test │ └── java │ └── com │ └── javatechie │ └── spring │ └── soap │ └── api │ └── SpringBootSopaWsApplicationTests.java ├── README.md └── pom.xml /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-soap-ws 2 | How to develop SOAP WebServices using Spring Boot 3 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/SpringBootSopaWsApplication.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.soap.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootSopaWsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootSopaWsApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/com/javatechie/spring/soap/api/SpringBootSopaWsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.soap.api; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootSopaWsApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/loaneligibility/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2019.06.07 at 09:07:01 PM IST 6 | // 7 | 8 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.javatechie.com/spring/soap/api/loanEligibility", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 9 | package com.javatechie.spring.soap.api.loaneligibility; 10 | -------------------------------------------------------------------------------- /src/main/resources/loaneligibility.xsd: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/emdpoint/LoanEligibilityindicatorEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.soap.api.emdpoint; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.ws.server.endpoint.annotation.Endpoint; 5 | import org.springframework.ws.server.endpoint.annotation.PayloadRoot; 6 | import org.springframework.ws.server.endpoint.annotation.RequestPayload; 7 | import org.springframework.ws.server.endpoint.annotation.ResponsePayload; 8 | 9 | import com.javatechie.spring.soap.api.loaneligibility.Acknowledgement; 10 | import com.javatechie.spring.soap.api.loaneligibility.CustomerRequest; 11 | import com.javatechie.spring.soap.api.service.LoanEligibilityService; 12 | 13 | @Endpoint 14 | public class LoanEligibilityindicatorEndpoint { 15 | 16 | private static final String NAMESPACE = "http://www.javatechie.com/spring/soap/api/loanEligibility"; 17 | @Autowired 18 | private LoanEligibilityService service; 19 | 20 | @PayloadRoot(namespace = NAMESPACE, localPart = "CustomerRequest") 21 | @ResponsePayload 22 | public Acknowledgement getLoanStatus(@RequestPayload CustomerRequest request) { 23 | return service.checkLoanEligibility(request); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/service/LoanEligibilityService.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.soap.api.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.javatechie.spring.soap.api.loaneligibility.Acknowledgement; 8 | import com.javatechie.spring.soap.api.loaneligibility.CustomerRequest; 9 | 10 | @Service 11 | public class LoanEligibilityService { 12 | 13 | public Acknowledgement checkLoanEligibility(CustomerRequest request) { 14 | Acknowledgement acknowledgement = new Acknowledgement(); 15 | List mismatchCriteriaList = acknowledgement.getCriteriaMismatch(); 16 | 17 | if (!(request.getAge() > 30 && request.getAge() <= 60)) { 18 | mismatchCriteriaList.add("Person age should in between 30 to 60"); 19 | } 20 | if (!(request.getYearlyIncome() > 200000)) { 21 | mismatchCriteriaList.add("minimum income should be more than 200000"); 22 | } 23 | if (!(request.getCibilScore() > 500)) { 24 | mismatchCriteriaList.add("Low CIBIL Score please try after 6 month"); 25 | } 26 | 27 | if (mismatchCriteriaList.size() > 0) { 28 | acknowledgement.setApprovedAmount(0); 29 | acknowledgement.setIsEligible(false); 30 | } else { 31 | acknowledgement.setApprovedAmount(500000); 32 | acknowledgement.setIsEligible(true); 33 | mismatchCriteriaList.clear(); 34 | } 35 | return acknowledgement; 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/config/SoapWSConfig.java: -------------------------------------------------------------------------------- 1 | package com.javatechie.spring.soap.api.config; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.core.io.ClassPathResource; 8 | import org.springframework.ws.config.annotation.EnableWs; 9 | import org.springframework.ws.transport.http.MessageDispatcherServlet; 10 | import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; 11 | import org.springframework.xml.xsd.SimpleXsdSchema; 12 | import org.springframework.xml.xsd.XsdSchema; 13 | 14 | @Configuration 15 | @EnableWs 16 | public class SoapWSConfig { 17 | 18 | @Bean 19 | public ServletRegistrationBean messageDispatcherServlet(ApplicationContext context) { 20 | MessageDispatcherServlet servlet = new MessageDispatcherServlet(); 21 | servlet.setApplicationContext(context); 22 | servlet.setTransformWsdlLocations(true); 23 | return new ServletRegistrationBean(servlet, "/ws/*"); 24 | } 25 | 26 | @Bean(name = "loanEligibility") 27 | public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema schema) { 28 | DefaultWsdl11Definition defaultWsdl11Definition = new DefaultWsdl11Definition(); 29 | defaultWsdl11Definition.setPortTypeName("LoanEligibilityindicator"); 30 | defaultWsdl11Definition.setLocationUri("/ws"); 31 | defaultWsdl11Definition.setTargetNamespace("http://www.javatechie.com/spring/soap/api/loanEligibility"); 32 | defaultWsdl11Definition.setSchema(schema); 33 | return defaultWsdl11Definition; 34 | 35 | } 36 | 37 | @Bean 38 | public XsdSchema schema() { 39 | return new SimpleXsdSchema(new ClassPathResource("loaneligibility.xsd")); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/loaneligibility/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2019.06.07 at 09:07:01 PM IST 6 | // 7 | 8 | 9 | package com.javatechie.spring.soap.api.loaneligibility; 10 | 11 | import javax.xml.bind.annotation.XmlRegistry; 12 | 13 | 14 | /** 15 | * This object contains factory methods for each 16 | * Java content interface and Java element interface 17 | * generated in the com.javatechie.spring.soap.api.loaneligibility package. 18 | *

An ObjectFactory allows you to programatically 19 | * construct new instances of the Java representation 20 | * for XML content. The Java representation of XML 21 | * content can consist of schema derived interfaces 22 | * and classes representing the binding of schema 23 | * type definitions, element declarations and model 24 | * groups. Factory methods for each of these are 25 | * provided in this class. 26 | * 27 | */ 28 | @XmlRegistry 29 | public class ObjectFactory { 30 | 31 | 32 | /** 33 | * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.javatechie.spring.soap.api.loaneligibility 34 | * 35 | */ 36 | public ObjectFactory() { 37 | } 38 | 39 | /** 40 | * Create an instance of {@link CustomerRequest } 41 | * 42 | */ 43 | public CustomerRequest createCustomerRequest() { 44 | return new CustomerRequest(); 45 | } 46 | 47 | /** 48 | * Create an instance of {@link Acknowledgement } 49 | * 50 | */ 51 | public Acknowledgement createAcknowledgement() { 52 | return new Acknowledgement(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.1.4.RELEASE 10 | 11 | 12 | com.javatechie 13 | spring-boot-sopa-ws 14 | 0.0.1-SNAPSHOT 15 | spring-boot-sopa-ws 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web-services 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-devtools 31 | runtime 32 | true 33 | 34 | 35 | wsdl4j 36 | wsdl4j 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-maven-plugin 50 | 51 | 52 | org.codehaus.mojo 53 | jaxb2-maven-plugin 54 | 1.6 55 | 56 | 57 | xjc 58 | 59 | xjc 60 | 61 | 62 | 63 | 64 | ${project.basedir}/src/main/resources/ 65 | ${project.basedir}/src/main/java 66 | false 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/loaneligibility/Acknowledgement.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2019.06.07 at 09:07:01 PM IST 6 | // 7 | 8 | 9 | package com.javatechie.spring.soap.api.loaneligibility; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlElement; 16 | import javax.xml.bind.annotation.XmlRootElement; 17 | import javax.xml.bind.annotation.XmlType; 18 | 19 | 20 | /** 21 | *

Java class for anonymous complex type. 22 | * 23 | *

The following schema fragment specifies the expected content contained within this class. 24 | * 25 | *

 26 |  * <complexType>
 27 |  *   <complexContent>
 28 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 29 |  *       <sequence>
 30 |  *         <element name="isEligible" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
 31 |  *         <element name="approvedAmount" type="{http://www.w3.org/2001/XMLSchema}long"/>
 32 |  *         <element name="CriteriaMismatch" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
 33 |  *       </sequence>
 34 |  *     </restriction>
 35 |  *   </complexContent>
 36 |  * </complexType>
 37 |  * 
38 | * 39 | * 40 | */ 41 | @XmlAccessorType(XmlAccessType.FIELD) 42 | @XmlType(name = "", propOrder = { 43 | "isEligible", 44 | "approvedAmount", 45 | "criteriaMismatch" 46 | }) 47 | @XmlRootElement(name = "Acknowledgement") 48 | public class Acknowledgement { 49 | 50 | protected boolean isEligible; 51 | protected long approvedAmount; 52 | @XmlElement(name = "CriteriaMismatch", required = true) 53 | protected List criteriaMismatch; 54 | 55 | /** 56 | * Gets the value of the isEligible property. 57 | * 58 | */ 59 | public boolean isIsEligible() { 60 | return isEligible; 61 | } 62 | 63 | /** 64 | * Sets the value of the isEligible property. 65 | * 66 | */ 67 | public void setIsEligible(boolean value) { 68 | this.isEligible = value; 69 | } 70 | 71 | /** 72 | * Gets the value of the approvedAmount property. 73 | * 74 | */ 75 | public long getApprovedAmount() { 76 | return approvedAmount; 77 | } 78 | 79 | /** 80 | * Sets the value of the approvedAmount property. 81 | * 82 | */ 83 | public void setApprovedAmount(long value) { 84 | this.approvedAmount = value; 85 | } 86 | 87 | /** 88 | * Gets the value of the criteriaMismatch property. 89 | * 90 | *

91 | * This accessor method returns a reference to the live list, 92 | * not a snapshot. Therefore any modification you make to the 93 | * returned list will be present inside the JAXB object. 94 | * This is why there is not a set method for the criteriaMismatch property. 95 | * 96 | *

97 | * For example, to add a new item, do as follows: 98 | *

 99 |      *    getCriteriaMismatch().add(newItem);
100 |      * 
101 | * 102 | * 103 | *

104 | * Objects of the following type(s) are allowed in the list 105 | * {@link String } 106 | * 107 | * 108 | */ 109 | public List getCriteriaMismatch() { 110 | if (criteriaMismatch == null) { 111 | criteriaMismatch = new ArrayList(); 112 | } 113 | return this.criteriaMismatch; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/com/javatechie/spring/soap/api/loaneligibility/CustomerRequest.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2019.06.07 at 09:07:01 PM IST 6 | // 7 | 8 | 9 | package com.javatechie.spring.soap.api.loaneligibility; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | import javax.xml.bind.annotation.XmlType; 16 | 17 | 18 | /** 19 | *

Java class for anonymous complex type. 20 | * 21 | *

The following schema fragment specifies the expected content contained within this class. 22 | * 23 | *

 24 |  * <complexType>
 25 |  *   <complexContent>
 26 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 27 |  *       <sequence>
 28 |  *         <element name="customerName" type="{http://www.w3.org/2001/XMLSchema}string"/>
 29 |  *         <element name="age" type="{http://www.w3.org/2001/XMLSchema}int"/>
 30 |  *         <element name="yearlyIncome" type="{http://www.w3.org/2001/XMLSchema}long"/>
 31 |  *         <element name="cibilScore" type="{http://www.w3.org/2001/XMLSchema}int"/>
 32 |  *         <element name="employmentMode" type="{http://www.w3.org/2001/XMLSchema}string"/>
 33 |  *       </sequence>
 34 |  *     </restriction>
 35 |  *   </complexContent>
 36 |  * </complexType>
 37 |  * 
38 | * 39 | * 40 | */ 41 | @XmlAccessorType(XmlAccessType.FIELD) 42 | @XmlType(name = "", propOrder = { 43 | "customerName", 44 | "age", 45 | "yearlyIncome", 46 | "cibilScore", 47 | "employmentMode" 48 | }) 49 | @XmlRootElement(name = "CustomerRequest") 50 | public class CustomerRequest { 51 | 52 | @XmlElement(required = true) 53 | protected String customerName; 54 | protected int age; 55 | protected long yearlyIncome; 56 | protected int cibilScore; 57 | @XmlElement(required = true) 58 | protected String employmentMode; 59 | 60 | /** 61 | * Gets the value of the customerName property. 62 | * 63 | * @return 64 | * possible object is 65 | * {@link String } 66 | * 67 | */ 68 | public String getCustomerName() { 69 | return customerName; 70 | } 71 | 72 | /** 73 | * Sets the value of the customerName property. 74 | * 75 | * @param value 76 | * allowed object is 77 | * {@link String } 78 | * 79 | */ 80 | public void setCustomerName(String value) { 81 | this.customerName = value; 82 | } 83 | 84 | /** 85 | * Gets the value of the age property. 86 | * 87 | */ 88 | public int getAge() { 89 | return age; 90 | } 91 | 92 | /** 93 | * Sets the value of the age property. 94 | * 95 | */ 96 | public void setAge(int value) { 97 | this.age = value; 98 | } 99 | 100 | /** 101 | * Gets the value of the yearlyIncome property. 102 | * 103 | */ 104 | public long getYearlyIncome() { 105 | return yearlyIncome; 106 | } 107 | 108 | /** 109 | * Sets the value of the yearlyIncome property. 110 | * 111 | */ 112 | public void setYearlyIncome(long value) { 113 | this.yearlyIncome = value; 114 | } 115 | 116 | /** 117 | * Gets the value of the cibilScore property. 118 | * 119 | */ 120 | public int getCibilScore() { 121 | return cibilScore; 122 | } 123 | 124 | /** 125 | * Sets the value of the cibilScore property. 126 | * 127 | */ 128 | public void setCibilScore(int value) { 129 | this.cibilScore = value; 130 | } 131 | 132 | /** 133 | * Gets the value of the employmentMode property. 134 | * 135 | * @return 136 | * possible object is 137 | * {@link String } 138 | * 139 | */ 140 | public String getEmploymentMode() { 141 | return employmentMode; 142 | } 143 | 144 | /** 145 | * Sets the value of the employmentMode property. 146 | * 147 | * @param value 148 | * allowed object is 149 | * {@link String } 150 | * 151 | */ 152 | public void setEmploymentMode(String value) { 153 | this.employmentMode = value; 154 | } 155 | 156 | } 157 | --------------------------------------------------------------------------------