How to create a soap website service in spring boot?

I followed this tutorial while producing a soap webservice in spring boot .

and it confused me a little. How and where is wsdl in the first place? This will generate wsdl from countries.xsd? I didn't understand how testing a web service in soapui is expected without a wsdl file.

Can anyone help me.

+3


source to share


3 answers


For this tutorial, they have followed the Bottom-Up approach. If you want to get WSDL in this example

http://<host>:<port>/ws/countries.wsdl

      

To get the country response



$ curl --header "content-type: text/xml" -d @request.xml http://localhost:8080/ws

      

Below is request.xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:gs="http://spring.io/guides/gs-producing-web-service">
   <soapenv:Header/>
   <soapenv:Body>
      <gs:getCountryRequest>
         <gs:name>Spain</gs:name>
      </gs:getCountryRequest>
   </soapenv:Body>
</soapenv:Envelope>

      

+2


source


Found a nice tutorial along with a video explanation for a top-down approach where we first create a wsdl and then use wsdl to generate the required classes. Using these classes, we then expose the webservice endpoint.

Using the maven-jaxb2-plugin, we can generate the required classes needed from wsdl.

       <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${maven-jaxb2-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
            </configuration>
        </plugin>

      



Next, using the ServletRegistrationBean, we register the MessageDispatcherServlet with Spring Boot. During this registration, the URI template for the servlet is set to / javainuse / ws / *. Using this path, the web container will map incoming HTTP requests to the MessageDispatcherServlet. DefaultWsdl11Definition provides standard WSDL 1.1 using the specified WSDL Hello World file. The MessageDispatcherServlet also automatically detects any WsdlDefinition defined in the application context.

Ref- Spring First Boot Contract Example + SOAP Web Services

+2


source


Here are the basic 5 steps to create a SOAP web service using Spring Boot.

  • Create XML Schema for Domain Definition
  • Generating Domain Classes from XML Schema
  • Create repository
  • Create service endpoint
  • Configuring the beans web service

See the blog post and YouTube video below for a detailed guide.

https://prateep.info/2017/12/12/basic-5-steps-to-produce-soap-web-service-with-spring-boot/ https://www.youtube.com/watch?v= SiFSNtDAIS0 & t = 277s

+1


source







All Articles