While I am not new to JAX-WS, (used it years ago w/ Sun Metro JAX-WS RI w/o issues)... much has changed and I have been involved in MANY other web services projects involving REST endpoints, mainly w/ Spring Boot the past few years.
I am now involved in another project where the server stack is Wildfly 23 and they are using SOAP web services. I have a written a simple WAR project w/ an annotated Java class implementing an annotated Java interface. (the term is SEI in the documentation, it's been a few years). I just want to understand how JAX-WS services deploy and how the WSDL is accessed.
Service implementation class
package com.example.jaxws.ws;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.jws.soap.SOAPBinding.Style;
@WebService(
serviceName = "EmployeeService",
endpointInterface = "com.example.jaxws.ws.EmployeeService"
)
@SOAPBinding(
style = Style.DOCUMENT
)
public class EmployeeServiceImpl implements EmployeeService {
public EmployeeServiceImpl() {
}
@WebMethod
public Employee getEmployee(int id) {
return null;
}
@WebMethod
public Employee addEmployee(int id, String name) {
return new Employee(id, name);
}
}
Service interface:
package com.example.jaxws.ws;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style= SOAPBinding.Style.DOCUMENT)
public interface EmployeeService {
@WebMethod
Employee getEmployee(int id);
@WebMethod
Employee addEmployee(int id, String name);
}
The web.xml file looks like this (effectively an empty default)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
</web-app>
Another post said one needs a jboss-web.xml, (same location /WEB-INF) so this was added
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="10.0"
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_10_0.xsd">
<context-root>/employee-service</context-root>
</jboss-web>
Finally, the pom.xml contains this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>JAXWS_Services</artifactId>
<version>1.0-SNAPSHOT</version>
<name>JAXWS_Services</name>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>
The WAR project is added an Artifact to the Server instance within IntelliJ where a Wildfly run configuration was created. Starting the server shows ZERO errors, a context-root path created matching the jboss-web.xml. Yet navigating to anywhere on that context-root path results in a "Forbidden" error page AND a path to the WSDL (that I think should work based on other code I've seen), yields a 404 😔)
Clearly, I am missing a BIG something. Any insight would be appreciated.
Console output from startup:
Connected to server
[2023-10-31 11:00:37,551] Artifact JAXWS_Services:war: Artifact is being deployed, please wait...
23:00:37,763 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "JAXWS_Services-1.0-SNAPSHOT.war" (runtime-name: "JAXWS_Services-1.0-SNAPSHOT.war")
23:00:39,883 INFO [org.infinispan.CONTAINER] (ServerService Thread Pool -- 28) ISPN000128: Infinispan version: Infinispan 'Corona Extra' 11.0.9.Final
23:00:39,965 INFO [org.infinispan.CONFIG] (MSC service thread 1-6) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
23:00:39,968 INFO [org.infinispan.CONFIG] (MSC service thread 1-6) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
23:00:40,115 INFO [org.infinispan.PERSISTENCE] (ServerService Thread Pool -- 28) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.spi.marshalling.InfinispanProtoStreamMarshaller'
23:00:40,452 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 28) WFLYCLINF0002: Started http-remoting-connector cache from ejb container
23:00:40,767 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 8) WFLYUT0021: Registered web context: '/employee-service' for server 'default-server'
23:00:40,852 INFO [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "JAXWS_Services-1.0-SNAPSHOT.war" (runtime-name : "JAXWS_Services-1.0-SNAPSHOT.war")
[2023-10-31 11:00:40,872] Artifact JAXWS_Services:war: Artifact is deployed successfully
[2023-10-31 11:00:40,872] Artifact JAXWS_Services:war: Deploy took 3,321 milliseconds
While the logging shows successful deployment and the establishment of the context-root path... I am not seeing evidence that the coded "web service" is actually running in the container.
You likely need to upgrade WildFly. WildFly 23 is a Jakarta EE 8 container. You potentially could use WildFly 23 Preview, however I would not suggest that. You should upgrade to the latest WildFly, at the moment it's 30.0.0.Final, which is a Jakarta EE 10 container.
Jakarta EE 8 still uses the javax
namespace where as Jakarta EE 9+ uses the jakarta
namespace. Your dependencies are Jakarta EE 9 depencies and your code uses the jakarta
namespace, therefore requiring a Jakarta EE 9+ container. My personal opinion would be to skip Jakarta EE 9.1 and go straight to Jakarta EE 10.