【问题标题】:Setting a JBoss / Wildfly webservice endpoint correctly (jboss-web.xml)正确设置 JBoss / Wildfly Web 服务端点 (jboss-web.xml)
【发布时间】:2021-08-05 03:00:43
【问题描述】:

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

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>

我尝试过的步骤

我试过设置 到:

  • /
  • /ws/*

但我还是无法到达终点

我们将不胜感激。

【问题讨论】:

    标签: java spring-boot soap wildfly endpoint


    【解决方案1】:

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

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

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-21
      • 2020-12-08
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多