【发布时间】:2014-11-16 13:20:02
【问题描述】:
我正在使用CXF 和wsdl2java 来自动生成网络服务类。
问题:不知何故,我想连接的网络服务有一些元素的重复名称:
Two declarations cause a collision in the ObjectFactory class
xsd 是这样的:
<xs:schema targetNamespace="http://thenamespace">
<xs:complexType name="ViolatingName">
...
</xs:complexType>
<xs:element name="ViolatingName" nillable="true" type="tns:ViolatingName"/>
</xs:schema>
xsd 本身被导入到用于自动生成 jaxb 类的 wsdl 中,如下所示:
<wsdl:types>
<xsd:schema targetNamespace="http://imports">
<xsd:import schemaLocation="https://path.to.xsd" namespace="http://thenamespace" />
我正在尝试使用jaxb-bindings.xml:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.1">
<jaxb:bindings schemalocation="https://path.to.xsd" node="//xs:schema">
<jaxb:bindings node=".//xs:element[@name='ViolatingName']">
<jaxb:property name="ViolatingNameBinding" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
结果:
[ERROR] XPath evaluation of "//xs:schema" results in empty target node (org.apache.cxf:cxf-codegen-plugin:3.0.1:wsdl2java:generate-sources:generate-sources)
为什么node 在这里错了? xsd 有一个xs:schema 标签,那为什么会失败呢?
有趣的事实:当我使用任何 xpath 工具时,将 XSD 下载到我的本地计算机并检查路径,然后 //xs:schema/xs:element[@name='ViolatingName'] 评估为正确的标记。
【问题讨论】:
-
在标签绑定的 xs:schema 上缺少双 '//'..
-
我在上面也做了调整,但结果是一样的...
标签: java xml web-services jaxb cxf