正确设置 JBoss / Wildfly 网络服务端点 (jboss-web.xml)

Setting a JBoss / Wildfly webservice endpoint correctly (jboss-web.xml)

我使用 Spring Boot 创建了一个小的 SOAP 网络服务,包含以下文件(仅显示相关文件):

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"));
    }
}

application.properties

server.port=9090

Main.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>

我试过的步骤

我试过设置 至:

但我仍然无法到达终点

任何输入将不胜感激。

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

回答

...you access the WSDL at:

http://localhost:8080//services/hello?wsdl A B C D

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