如何防止 JBoss 将 JAX-WS XSD 导入 URL 重写为 HTTP

Howto prevent JBoss from rewriting JAX-WS XSD import URLs to HTTPs

我们在 JBoss EAP 6.4.0 (JBoss AS 7.5.0) 的 WAR 中部署了一个 JAX-WS 网络服务,它提供预定义的 WSDL 和 XSD:

@WebService(endpointInterface = "package.MyPortType",
    targetNamespace = "http://target.name.space",
    wsdlLocation = "/WEB-INF/classes/myService.wsdl",
    serviceName = "myService",
    portName = "myServicePort")
public class MyService implements MyPortType {
...
}

JBoss 正确部署网络服务并将给定的 WSDL 发布为 http://localhost:8080/myApp/myServicehttp://localhost:8080/myApp/myService?wsdl

我们遇到的问题出在WSDL中的XSD导入。在原始的 WSDL 中它看起来像:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="mySchema.xsd" />

但是 JBoss 将其重写为

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="https://localhost:8443/myApp/myService?xsd=mySchema.xsd" />

这不起作用,因为我们既没有在 standalone.xml 中定义 HTTPs 连接器也没有 HTTPs 套接字绑定。所以 JBoss 是 运行,没有任何 HTTPs 连接。 我们没有关于 Web 服务部署的任何其他配置文件。

为什么会以这种错误的方式重写导入,我们如何防止这种情况发生?

来自 JAX-WS 规范:

A JAX-WS implementation MUST patch the location attributes of all wsdl:import and xsd:import statement in local documents that point to local documents...

...Please note that, although the catalog facility (see 4.4) is used to resolve any absolute URLs encountered while processing the root description document or any documents transitively reachable from it via wsdl:import and xsd:import statements, those absolute URLs will not be rewritten when the importing document is published, since documents resolved via the catalog are not considered local, even if the catalog maps them to resources packaged with the application.

所以你有 为什么 位置被重写,特别是因为 XSD 是本地的。

为了避免重写,您需要在原始 WSDL 的 schemaLocation 字段中指定您选择的绝对 URL。

至于为什么位置改写错误? some chatter on the JBoss issue board 可能表明您的 JAX-WS 实现中存在错误