How to use WSDL with spring-boot?

前端 未结 5 2068
臣服心动
臣服心动 2020-12-25 14:48

I have WSDL and schema files provided by client. I need to create Spring-boot SOAP web service with this WSDL file. I have google it and all the examples that I can find, th

5条回答
  •  不知归路
    2020-12-25 15:30

    • First define the define XSD for Request and Response.

    • Then Configuring the Endpoint. (i.e Create a Bean class and a controller class)

    • Then Configure the Message Dispatcher Servlet to Receive the Request.

    • Then add wsdl4j dependency to the pom.xml.

    • Then add the web service config class as below.

      @Bean(name = "students")
        public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema studentsSchema) {
          DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
          definition.setPortTypeName("StudentPort");
          definition.setTargetNamespace("http://in28minutes.com/students");
          definition.setLocationUri("/ws");
          definition.setSchema(studentsSchema);
          return definition;
        }
      
        @Bean
        public XsdSchema studentsSchema() {
          return new SimpleXsdSchema(new ClassPathResource("student-details.xsd"));
        }
      

    Then if you start the spring boot and access the wsdl url then you can able to see the wsdl link. Please refer this blog[1] for detailed information.

    [1] https://dzone.com/articles/creating-a-soap-web-service-with-spring-boot-start

提交回复
热议问题