我正在使用 CXF 将 WSDL 转换为 Java。启用密钥时-autoNameResolution
,CXF 会生成许多具有相同内容的文件。有什么办法可以避免吗?
为了避免嵌套静态类,我启用了<jaxb:globalBindings localScoping="toplevel">
. 正如您在 WSDL 元素中看到的那样,“Apple”被引用了 3 次。不幸的是,我无法更改 WSDL。CXF 相应地创建
Apple.java、Apple2.java、Apple3.java或在-autoNameResolution
未设置标志时崩溃。
<xs:element name="Forest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="99" minOccurs="0" name="Apple">
<xs:complexType>
<xs:sequence>
<xs:element name="Size" type="xsd:string" />
<xs:element name="Color" type="xsd:string" />
<xs:element name="Taste" type="xsd:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="TreeOne">
<xs:complexType>
<xs:sequence>
<xs:element name="Branch1" type="xsd:string">
</xs:element>
<xs:element maxOccurs="99" minOccurs="0" name="Apple">
<xs:complexType>
<xs:sequence>
<xs:element name="Size" type="xsd:string" />
<xs:element name="Color" type="xsd:string" />
<xs:element name="Taste" type="xsd:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="TreeTwo">
<xs:complexType>
<xs:sequence>
<xs:element name="BranchTwo" type="xsd:string">
</xs:element>
<xs:element maxOccurs="99" minOccurs="0" name="Apple">
<xs:complexType>
<xs:sequence>
<xs:element name="Size" type="xsd:string" />
<xs:element name="Color" type="xsd:string" />
<xs:element name="Taste" type="xsd:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
有没有办法教wsdl2java不要创建Apple2.java和 Apple3.java 并在所有三种情况下都引用 Apple.java?通过绑定,我可以将名称更改为Apple2->Peach、Apple3->Watermelon之类的名称,但这不是我想要的。很明显,所有三个苹果都有相同的字段集,并且实际上是相同的?有没有办法解决这个问题?可能是一些重构 cxf 生成的代码的重构插件?