我有一个定义远程设备的 SOAP 消息的 XSD。我想使用这个 XSD 并从中生成 Java 源代码来创建这些消息。XSD 中的一条消息的示例如下:
<xs:element name="get-ethernet-stats">
<xs:annotation>
<xs:documentation>Ethernet stats information</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="mode" type="response-mode"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="get-ethernet-stats-resp">
<xs:complexType>
<xs:annotation>
<xs:documentation>Ethernet Stats</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element ref="status"/>
<xs:element name="result" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="rx" type="xs:int"/>
<xs:element name="tx" type="xs:int"/>
<xs:element name="drops" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
关于如何做到这一点的任何建议?我查看了 JAXB,但没有原始源文件,当我运行“xjc file.xsd”来获取源文件时,这里是输出的一部分:
parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "file.MemosReceipt" is already in use. Use a class customization to resolve this conflict.
line 7669 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] (Relevant to above error) another "MemosReceipt" is generated from here.
line 8242 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] A class/interface with the same name "file.InstructionsReceipt" is already in use. Use a class customization to resolve this conflict.
line 7720 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] (Relevant to above error) another "InstructionsReceipt" is generated from here.
line 8341 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 7686 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] (Related to above error) This is the other declaration.
line 8267 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 8626 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
[ERROR] (Related to above error) This is the other declaration.
line 6114 of file:/Users/rwb7041/Documents/file/xsd/file.xsd.xsd
Failed to produce code.