Search code examples
javaspring-bootsoapwildflyendpoint

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


I made a little SOAP web service using Spring Boot, with the following files (only relevant files are shown):

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

Problem description:

When I run Main.Java from Eclipse, a Tomcat instance is deployed. Visiting the address http://localhost:9090/ws/consultas.wsdl. shows the WSDL description file, and SOAPUI is able to consume the web services without a problem.

The problem starts when I pack the .war and deploy it on wildfly-23.0.2.Final. The context root is always set to /soap-web-service-0.0.1-SNAPSHOT.

Edit 2021 05 17

I was able to change the WildFly endpoint by creating a jboss-web.xml file in the folder src\main\webapp\WEB-INF, with the following contents:

<?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>

Steps I tried

I tried setting to:

  • /
  • /ws/*

But I'm still unable to reach the endpoint

Any input will be greatly appreciated.


Solution

  • UPDATE Months later I just found the answer by accident, answered by user @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