JAX-WS RI在运行时生成WSDL,默认情况下,在导入的示意图中使用公共URL生成WSDL

发布于 2025-01-21 06:22:33 字数 622 浏览 0 评论 0 原文

在使用JAX-WS RI用于发布使用预定的 .wsdl .xsd 文件的生成的存根实现的SOAP端点时,它会自动为已发布的端点生成相应的WSDL文件。例如,在 http:// localhost:8081/ep 发布的端点上有其WSDL文件,位于 http:// localhost:8081/ep?wsdl ,其中包含其中的导入其他模式文件又可以导入更多文件。

它是自动生成的。

...
<xs:import namespace="http://www.w3.org/2005/08/addressing" 
           schemaLocation="http://www.w3.org/2006/03/addressing/ws-addr.xsd"/>
...

问题是,在 .xsd 文件中, 。生成的存根包括 ws-addr.xsd 的类,因此JAX-WS RI应该能够从这些存根中生成并发布 .xsd

如何将其强加于对其他名称空间模式的所需 .xsd 架构本身,为什么这首先使用公共位置?

While using JAX-WS RI for publishing SOAP endpoints implemented using generated stubs from predetermined .wsdl and .xsd files, it automatically generates corresponding WSDL files for the published endpoint. For example an endpoint published at http://localhost:8081/ep has its WSDL file at http://localhost:8081/ep?wsdl with it containing imports of other schema files which in turn can import more files.

Issue is that one such import in an .xsd file is automatically generated with a reference to public URL as such:

...
<xs:import namespace="http://www.w3.org/2005/08/addressing" 
           schemaLocation="http://www.w3.org/2006/03/addressing/ws-addr.xsd"/>
...

This can be an issue when trying to parse this endpoint's WSDL in an environment with no public internet connectivity. Generated stubs include classes from ws-addr.xsd, so JAX-WS RI should be able to generate and publish the .xsd from those stubs.

How could this be forced to generate the required .xsd schema itself as it does for other namespace schemas and why does this use a public location in the first place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮光沉寂 2025-01-28 06:22:33

问题在于,其他一些依赖关系覆盖了模式的默认设置。由于该项目使用Jax-ws RI,它还包括 jakarta.xml.ws-api 的依赖项,其中包括 package> infage> info.java in javax中。

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS,
                                     location="http://www.w3.org/2006/03/addressing/ws-addr.xsd")
package javax.xml.ws.wsaddressing;

​。

通过一些自动配置魔术,这告诉JAX-WS RI在引用指定名称空间时使用给定的公共位置。位置的默认值为 ## Generate ,它使架构生成器生成所需的组件。

因此,为了覆盖这一点,我们可以将自己的 package> info.java 文件添加到我们自己的代码库中,但在同一软件包中中,带有相同的注释,但默认为位置的值:(

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS)
package javax.xml.ws.wsaddressing;

位置密钥表示使用默认值)

,结果是生成的架构使用生成的地址 .xsd 文件而不是公共文件:

<xs:import namespace="http://www.w3.org/2005/08/addressing"
           schemaLocation="http://localhost:8081/ep?xsd=10"/>

The issue is that some other dependency overwrites the default setting for the schema. As the project uses JAX-WS RI, it also includes a dependency for jakarta.xml.ws-api which includes a package-info.java file in javax.xml.ws.wsaddressing package containing the following titbit:

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS,
                                     location="http://www.w3.org/2006/03/addressing/ws-addr.xsd")
package javax.xml.ws.wsaddressing;

where W3CEndpointReference.NS is http://www.w3.org/2005/08/addressing.

This, through some automatic configuration magic, tells JAX-WS RI to use the given public location when referencing the specified namespace. The default value for location is ##generate which makes the schema generator generate the required components.

So in order to override this, we can add our own package-info.java file into our own codebase but in the same package, with the same annotation but with the default value for the location:

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS)
package javax.xml.ws.wsaddressing;

(no location key means default value is used)

And result is that the generated schema uses a generated addressing .xsd file instead of a public one:

<xs:import namespace="http://www.w3.org/2005/08/addressing"
           schemaLocation="http://localhost:8081/ep?xsd=10"/>
最舍不得你 2025-01-28 06:22:33

我找到了一个使用 meta-inf/jax-ws-catalog.xml 的清洁解决方案。在这里,您可以配置CXF应在哪里获取资源,请参见

示例:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <system systemId="http://www.w3.org/2006/03/addressing/ws-addr.xsd" 
            uri="classpath:Schemas/ws-addr.xsd"/>
</catalog>

我们必须将 ws-addr.xsd 将主/资源/架构。

CXF开发人员似乎在这里做类似的事情: meta-inf/jax-ws-catalog.xml在Systests中

在引擎盖下,

I found a cleaner solution with META-INF/jax-ws-catalog.xml. Here you can configure where CXF should fetch the resources, see https://docs.oracle.com/cd/E13222_01/wls/docs103/webserv_adv/xml.html

Example:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <system systemId="http://www.w3.org/2006/03/addressing/ws-addr.xsd" 
            uri="classpath:Schemas/ws-addr.xsd"/>
</catalog>

We have to put the ws-addr.xsd to src/main/resources/Schemas.

Seems like CXF developers do similar things here: META-INF/jax-ws-catalog.xml in systests.

Under the hood, the OASISCatalogManager will manage this mapping.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文