【发布时间】:2018-09-06 07:35:31
【问题描述】:
我正在使用 WSDL 来生成 Java 类,以访问 Zuora SOAP API。
不幸的是,此 WSDL 存在冲突:Maven CXF 插件抛出错误,并显示“两个声明导致 ObjectFactory 类发生冲突”消息。
冲突发生在 Invoice.PaymentAmount 和 Payment.Amount 之间
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:zns="http://api.zuora.com/"
xmlns:ons="http://object.api.zuora.com/"
xmlns:fns="http://fault.api.zuora.com/"
targetNamespace="http://api.zuora.com/">
<types>
<schema attributeFormDefault="qualified" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://object.api.zuora.com/">
<import namespace="http://api.zuora.com/" />
<complexType name="zObject">
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull" nillable="true" type="string" />
<element minOccurs="0" maxOccurs="1" name="Id" nillable="true" type="zns:ID" />
</sequence>
</complexType>
<complexType name="Invoice" >
<complexContent>
<extension base="ons:zObject">
<sequence>
<element minOccurs="0" name="AccountId" nillable="true" type="zns:ID" />
<element minOccurs="0" name="AdjustmentAmount" nillable="true" type="decimal" />
<element minOccurs="0" name="PaymentAmount" nillable="true" type="decimal" />
<!--more elements-->
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="Payment" >
<complexContent>
<extension base="ons:zObject">
<sequence>
<element minOccurs="0" name="AccountId" nillable="true" type="zns:ID" />
<element minOccurs="0" name="AccountingCode" nillable="true" type="string" />
<element minOccurs="0" name="Amount" nillable="true" type="decimal" />
<!--more elements-->
</sequence>
</extension>
</complexContent>
</complexType>
<!--more types-->
诀窍似乎是this post建议的外部绑定文件.. https://community.zuora.com/t5/API/quot-Two-declarations-cause-a-collision-in-the-ObjectFactory/td-p/11265
但是没有代码示例;我不知道如何编写这样的绑定文件。
我试过了:
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<jaxb:bindings schemaLocation="zuora.a.77.0.wsdl">
<jaxb:bindings node="//xs:element[@name='PaymentAmount']/xs:complexType">
<jaxb:factoryMethod name="PaymentAmout2"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
但是好像太简单了,抛出一个
"file:/home/kemkem/Work/repo/asap/tooling-zuora/src/main/resources
/wsdl/zuora.a.77.0.wsdl" is not a part of this compilation.
Is this a mistake for "file:/home/kemkem/Work/repo/asap/tooling-zuora/
src/main/resources/wsdl/zuora.a.77.0.wsdl#types1"
有没有人对此有更好的方法?
【问题讨论】: