简而言之,我有一个我无法控制的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>
如您所见,我尝试为这两个complexType分配相同的类名,但果然,编译器会抛出此异常:
[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
知道如何实现这一目标吗? 请注意:我在这里使用了内联绑定,我在生产中无法做到这一点。但是,将解决方案移植到外部绑定文件并不困难,我希望......