jboss Wildfly 23服务器-简单的JAX-WS部署-访问WSDL的所有尝试都是“禁止”或“未找到”

uwopmtnx  于 2023-11-19  发布在  其他
关注(0)|答案(1)|浏览(225)

虽然我对JAX-WS并不陌生,(几年前使用过它w/ Sun Metro JAX-WS RI w/o issues).很多事情都发生了变化,我参与了许多其他涉及REST端点的Web服务项目,主要是过去几年的w/ Sping Boot 。
我现在参与了另一个项目,其中服务器堆栈是Wildfly 23,他们使用SOAP Web服务。我编写了一个简单的WAR项目w/一个带注解的Java类,实现了一个带注解的Java接口。(文档中的术语是SEI,已经有几年了)。我只是想了解JAX-WS服务如何部署以及如何访问WSDL。
服务实现类

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

字符串
服务接口:

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


x1c 0d1x的数据
xml文件如下所示(实际上是一个空的默认值)

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


另一个帖子说需要一个jboss-web.xml,(相同的位置/WEB-INF),所以添加了这个

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


最后,pom.xml包含以下内容:

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


WAR项目被添加到IntelliJ中的服务器示例中,在那里创建了Wildfly运行配置。启动服务器显示零错误,创建的上下文根路径与jboss-web.xml匹配。然而,导航到上下文根路径上的任何地方都会导致“Forbidden”错误页面和WSDL路径(我认为应该基于我见过的其他代码工作),产生404错误。
很明显,我错过了一个大的东西。任何见解将不胜感激。

启动控制台输出:

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


虽然日志记录显示成功部署和上下文根路径的建立.我没有看到编码的“Web服务”实际上在容器中运行的证据。

ss2ws0br

ss2ws0br1#

你可能需要升级WildFly。WildFly 23是一个Jakarta EE 8容器。你可能可以使用WildFly 23预览版,但我不建议这样做。你应该升级到最新的WildFly,目前它是30.0.0.Final,这是一个Jakarta EE 10容器。
Jakarta EE 8仍然使用javax命名空间,而Jakarta EE 9+使用jakarta命名空间。您的依赖项是Jakarta EE 9依赖项,您的代码使用jakarta命名空间,因此需要Jakarta EE 9+容器。我个人的意见是跳过Jakarta EE 9.1,直接进入Jakarta EE 10。

相关问题