在使用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?
发布评论
评论(2)
问题在于,其他一些依赖关系覆盖了模式的默认设置。由于该项目使用Jax-ws RI,它还包括
jakarta.xml.ws-api
的依赖项,其中包括package> infage> info.java
injavax中。
。
通过一些自动配置魔术,这告诉JAX-WS RI在引用指定名称空间时使用给定的公共位置。位置的默认值为
## Generate
,它使架构生成器生成所需的组件。因此,为了覆盖这一点,我们可以将自己的
package> info.java
文件添加到我们自己的代码库中,但在同一软件包中中,带有相同的注释,但默认为位置的值:(否
位置
密钥表示使用默认值),结果是生成的架构使用生成的地址
.xsd
文件而不是公共文件: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 apackage-info.java
file injavax.xml.ws.wsaddressing
package containing the following titbit:where
W3CEndpointReference.NS
ishttp://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:(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:我找到了一个使用
meta-inf/jax-ws-catalog.xml
的清洁解决方案。在这里,您可以配置CXF应在哪里获取资源,请参见示例:
我们必须将
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.htmlExample:
We have to put the
ws-addr.xsd
tosrc/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.