最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

spring boot - SpringBoot SOAP configuration not called - Stack Overflow

matteradmin6PV0评论

I try to learn SpringBoot SOAP web-service implementation and don't understand why configuration methods not called. The configuration bean looks like this:

package hu.infokristaly.fileservice;

import .springframework.boot.web.servlet.ServletRegistrationBean;
import .springframework.context.ApplicationContext;
import .springframework.context.annotation.Bean;
import .springframework.context.annotation.Configuration;
import .springframework.core.io.ClassPathResource;
import .springframework.ws.config.annotation.EnableWs;
import .springframework.ws.config.annotation.WsConfigurerAdapter;
import .springframework.ws.transport.http.MessageDispatcherServlet;
import .springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import .springframework.xml.xsd.SimpleXsdSchema;
import .springframework.xml.xsd.XsdSchema;

@Configuration
@EnableWs
public class SOAPWebServiceConfig extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/ws/*");
    }

    @Bean(name = "FileUploadServiceWsdl")
    public DefaultWsdl11Definition calculatorServiceDefinition(XsdSchema calculatorServiceSchema) {
        DefaultWsdl11Definition wsdlDefinition = new DefaultWsdl11Definition();
        wsdlDefinition.setPortTypeName("FileUploadServicePort");
        wsdlDefinition.setLocationUri("/ws/fileuplaod-service");
        wsdlDefinition.setTargetNamespace(";);
        wsdlDefinition.setSchema(fileUplaodServiceSchema());
        return wsdlDefinition;
    }

    @Bean
    public XsdSchema fileUplaodServiceSchema() {
        return new SimpleXsdSchema(new ClassPathResource("fileupload.xsd"));
    }

}

In other project the messageDispatcherServlet / fileUplaodServiceSchema / calculatorServiceDefinition methods called on startup.

Here is my Github repo

Please help me find solution. It's maybe just some misspell but I can't see the problem. Thanks for all suggestions!

I try to learn SpringBoot SOAP web-service implementation and don't understand why configuration methods not called. The configuration bean looks like this:

package hu.infokristaly.fileservice;

import .springframework.boot.web.servlet.ServletRegistrationBean;
import .springframework.context.ApplicationContext;
import .springframework.context.annotation.Bean;
import .springframework.context.annotation.Configuration;
import .springframework.core.io.ClassPathResource;
import .springframework.ws.config.annotation.EnableWs;
import .springframework.ws.config.annotation.WsConfigurerAdapter;
import .springframework.ws.transport.http.MessageDispatcherServlet;
import .springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import .springframework.xml.xsd.SimpleXsdSchema;
import .springframework.xml.xsd.XsdSchema;

@Configuration
@EnableWs
public class SOAPWebServiceConfig extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/ws/*");
    }

    @Bean(name = "FileUploadServiceWsdl")
    public DefaultWsdl11Definition calculatorServiceDefinition(XsdSchema calculatorServiceSchema) {
        DefaultWsdl11Definition wsdlDefinition = new DefaultWsdl11Definition();
        wsdlDefinition.setPortTypeName("FileUploadServicePort");
        wsdlDefinition.setLocationUri("/ws/fileuplaod-service");
        wsdlDefinition.setTargetNamespace("http://infokristaly.hu/fileuplaod");
        wsdlDefinition.setSchema(fileUplaodServiceSchema());
        return wsdlDefinition;
    }

    @Bean
    public XsdSchema fileUplaodServiceSchema() {
        return new SimpleXsdSchema(new ClassPathResource("fileupload.xsd"));
    }

}

In other project the messageDispatcherServlet / fileUplaodServiceSchema / calculatorServiceDefinition methods called on startup.

Here is my Github repo

Please help me find solution. It's maybe just some misspell but I can't see the problem. Thanks for all suggestions!

Share Improve this question asked Nov 16, 2024 at 10:57 Papp ZoltánPapp Zoltán 2091 silver badge8 bronze badges 1
  • I moved the FileUploadEndpoint / SOAPWebServiceConfig / FileUploadImpl to the same directory as ForrasUploadSoapServerApplication and configuration loaded. How funny. – Papp Zoltán Commented Nov 16, 2024 at 12:02
Add a comment  | 

1 Answer 1

Reset to default 0

If your configuratoins are in different packages, use @ComponentScan on application like this:

@SpringBootApplication
@ComponentScan(basePackages = {"hu.infokristaly"})
public class ForrasUploadSoapServerApplication {
    private static ApplicationContext applicationContext;

    public static void main(String[] args) {
       SpringApplication.run(ForrasUploadSoapServerApplication.class, args);
    }

}
Post a comment

comment list (0)

  1. No comments so far