简而言之,我有一个我无法控制的 wsdl,它定义了两种非常相似且满足相同目的的类型:
<xsd:complexType name="TypeA_CommData">
<xsd:annotation>
<xsd:appinfo>
<jxb:class name="CommunicationData"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="CommunicationPreference" type=TypeA_CommDataPrfComm" minOccurs="0" />
<xsd:element name="Telephone" type="TypeA_CommDataTele" minOccurs="0" maxOccurs="2" />
<xsd:element name="Facsimile" type="TypeA_CommDataFacs" minOccurs="0" maxOccurs="2" />
<xsd:element name="EMail" type="TypeA_CommDataEml" minOccurs="0" maxOccurs="2" />
</xsd:sequence>
</xsd:complexType>
...
<xsd:complexType name="TypeB_CommData">
<xsd:annotation>
<xsd:appinfo>
<jxb:class name="CommunicationData"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="CommunicationPreference" type=TypeB_CommDataPrfComm" minOccurs="0" />
<xsd:element name="Telephone" type="TypeB_CommDataTele" minOccurs="0" maxOccurs="2" />
<xsd:element name="Facsimile" type="TypeB_CommDataFacs" minOccurs="0" maxOccurs="2" />
<xsd:element name="EMail" type="TypeB_CommDataEml" minOccurs="0" maxOccurs="2" />
</xsd:sequence>
</xsd:complexType>
如您所见,我试图为这两个 complexTypes 分配相同的类名,但果然,编译器抛出了这个异常:
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 832 of file:/my.wsdl
[ERROR] (Related to above error) This is the other declaration.
line 3078 of file:/my.wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 3078 of file:/my.wsdl
[ERROR] (Related to above error) This is the other declaration.
line 832 of file:/my.wsdl
知道我怎么能做到这一点吗?请注意:我在这里使用了内联绑定,我将无法在生产中执行此操作。但是将解决方案移植到外部绑定文件应该不难,我希望......