Spring Boot Soap Webservice Example

1. Technology stack

  • maven, eclipse,  JDK1.8 - Development enviroment
  • Springboot - Underlying application framework
  • wsdl4j - for publishing wsdl for our service
  • soapUI - for test our service
  • JAXB maven plugin - for code generation

2. Create Spring Boot Project

Create one spring boot project from SPRING INITIALIZR.

3. Create Soap Domain Model And Generator Java Code

student.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="https://www.howtodoinjava.com/xml/school"
targetNamespace="https://www.howtodoinjava.com/xml/school" elementFormDefault="qualified">
 
    <xs:element name="StudentDetailsRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
 
    <xs:element name="StudentDetailsResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Student" type="tns:Student"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
 
    <xs:complexType name="Student">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="standard" type="xs:int"/>
            <xs:element name="address" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
     
</xs:schema>

place above file in resources folder of the project

Add JAXB maven plugin for XSD to java object generation

by Will use WE jaxb2-maven-pluginto the Generate Efficiently classes at The Domain. Add this plugin to the pom.xml file.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
        <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
        <clearOutputDir>false</clearOutputDir>
    </configuration>
</plugin>

 To be added...

Description link

Guess you like

Origin www.cnblogs.com/chenqr/p/11130031.html