1

我使用 Spring Boot 制作了一个小 SOAP Web 服务,其中包含以下文件(仅显示相关文件):

WebServiceConfig.Java

@EnableWs
@Configuration
public class WebServiceConfig {
    

    @Bean
    public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext context) {
        MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
        messageDispatcherServlet.setApplicationContext(context);
        messageDispatcherServlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean<MessageDispatcherServlet>(messageDispatcherServlet, "/ws/*");
    }

    @Bean(name = "consultas")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema consultasSchema) {
        DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
        definition.setPortTypeName("ConsultasPort");
        definition.setTargetNamespace("http:/site.com/consultas");
        definition.setLocationUri("/ws");
        definition.setSchema(consultasSchema);   
    
        return definition;
    }

    @Bean
    public XsdSchema consultasSchema() {

        return new SimpleXsdSchema(new ClassPathResource("consultas.xsd"));
    }
}

应用程序属性

server.port=9090

主.Java

@SpringBootApplication
public class Main extends SpringBootServletInitializer {

    public static void main(String[] args) {
                    
        System.setProperty("org.jboss.logging.provider", "slf4j2");     
        SpringApplication.run(Main.class, args);                
    }
}

问题描述:

当我从 Eclipse 运行 Main.Java 时,会部署一个 Tomcat 实例。访问地址http://localhost:9090/ws/consultas.wsdl。显示 WSDL 描述文件,并且 SOAPUI 能够毫无问题地使用 Web 服务。

当我打包 .war 并将其部署在 wildfly-23.0.2.Final 上时,问题就开始了。上下文根始终设置为 /soap-web-service-0.0.1-SNAPSHOT。

编辑 2021 05 17

我可以通过在文件夹 src\main\webapp\WEB-INF 中创建一个 jboss-web.xml 文件来更改 WildFly 端点,其中包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
    <context-root>/ws/*</context-root>
</jboss-web>

我试过的步骤

我尝试设置为:

  • /
  • /ws/*

但我仍然无法到达终点

任何输入将不胜感激。

4

1 回答 1

1

更新几个月后,我偶然发现了答案,由用户@pascal-thivent回答

...您可以通过以下方式访问 WSDL:

http://localhost:8080//services/hello?wsdl ABCD

A is the host and port of the servlet container.
B is the name of the war file.
C comes from the url-pattern element in the web.xml file.
D comes from the ending stem of the url-pattern attribute in the sun-jaxws.xml file
于 2021-08-02T16:23:36.143 回答