gpt4 book ai didi

java - Apache CXF::wsdl2java 忽略公共(public)条目的目录配置

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:42 25 4
gpt4 key购买 nike

我正在使用 Apache CXF 2.7.6 wsdl2java并且该工具似乎忽略或未能找到公共(public)目录条目。特别是我有以下 <xs:import>在我的一个 XSD 文件中:

<xs:import namespace="http://www.ivoa.net/xml/STC/STCcoords/v1.10"/>

无法通过目录文件条目正确解决上述问题:

<public publicId="http://www.ivoa.net/xml/STC/STCcoords/v1.10" uri="STCcoords-v1.10.xsd"/>

如果我更改 <xs:import>通过添加 schemaLocation属性,即将其更改为:

<xs:import namespace="http://www.ivoa.net/xml/STC/STCcoords/v1.10" schemaLocation="http://www.ivoa.net/xml/STC/STCcoords/v1.10/>

它解析文件,但我的理解是这不是必需的,因为我不想编辑我提供的 XSD。

无论使用 OASIS XML 格式还是 TR9401 格式,行为都是相同的。

最佳答案

我从 Apache CXF 用户邮件列表中得到的答复是,XML 模式规范将这一点留给了实现,因此不被视为错误。

线程 here (帖子日期为 2013 年 9 月 26 日,在第 2 页,我似乎无法直接提供指向该页面的链接)。相关结论为here .我引用:

My thoughts on this:

1) According to the schema spec, if the schemaLocation hint isn't specified, it's up to the application to figure out how to resolve it if needed. Thus, I don't really consider this a "bug". We specifically just use the information provided and is part of the "compilation unit" (aka: wsdl).

2) Personally, I think it's pretty silly to NOT provide the schemaLocation and would STRONGLY STRONGLY recommend adding it. The only time I've ever seen it not specified is when importing schemas that are also embedded in the same wsdl (so there isn't a location).
When ever I see things like "up to the application" in specs, that, to me, is an interoperability nightmare. Just specify it.

3) That all said, the root issue would be in XmlSchema's SchemaBuilder class. If there isn't a schemaLocation, it assumes it's part of the compilation unit it's working on and continues. Doesn't try to resolve anything. If you want to pursue a patch or something, it would be around 680 of SchemaBuilder.java. But even changing that MAY require more support from CXF's side to pre-populate the namespaces it already knows to avoid it going off to the internet for them. Not really sure.

因此,可以确认:

  • 默认wsimport Oracle Java 7 附带的工具 确实 使用目录来解析 import 语句,即使没有 schemaLocation 属性。
  • Apache CXF 2.7.6 wsdl2java工具使用目录来解析没有schemaLocation 属性的import 语句
  • Apache CXF 社区不认为这是一个错误。

关于java - Apache CXF::wsdl2java 忽略公共(public)条目的目录配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19030035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com