问题描述
尝试使用 wsimport
为 SOAP 端点生成客户端.使用的 WSDL 和所有 XSD 文件都是本地副本.
Trying to use wsimport
to generate a client for a SOAP endpoint. The WSDL and all XSD files used are local copies.
这是正在执行的命令:
wsimport ./bwWsdl.xml -p com.generated -Xnocompile -d ../src -extension -keep -XadditionalHeaders -B-XautoNameResolution
这给出了这个错误:
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 16 of file:/schemas/newSchema.xsd
[ERROR] (Related to above error) This is the other declaration.
line 16 of file:/schemas/newSchema.xsd
请注意,报告的冲突的行号是相同的.
Note the line number is the same for the reported collision.
这是架构:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
version="2.004" id="OTA2003A2009A">
<xs:complexType name="TPA_ExtensionsType">
<xs:annotation>
<xs:documentation xml:lang="en">Description here.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:element name="TPA_Extensions" type="TPA_ExtensionsType">
<xs:annotation>
<xs:documentation xml:lang="en">More description here.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
我已尝试删除类型定义,但在许多其他地方都引用了它.
I've tried removing the type definition, but it's referenced in a slew of other places.
任何人都可以就如何让它发挥作用提供任何建议吗?
Could anyone please offer any advice for how to get this to work?
谢谢
以下是 WSDL 导入这些模式的行:
Here's the lines where the WSDL imports these schemas:
<definitions name='ResLookupGet' targetNamespace='http://org.jboss.ws/resLookupGet' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:http='http://schemas.xmlsoap.org/wsdl/http/' xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/' xmlns:ns='http://www.opentravel.org/OTA/2003/05/beta' xmlns:rq='http://www.opentravel.org/OTA/2003/05/betarq' xmlns:rs='http://www.opentravel.org/OTA/2003/05/betars' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://org.jboss.ws/resLookupGet' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types>
<xsd:schema targetNamespace='http://org.jboss.ws/resLookupGet' xmlns:tns='http://org.jboss.ws/resLookupGet' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betarq' schemaLocation='./schemas/FooAffiliateHeaderRQ.xsd'/>
<xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betarq' schemaLocation='./schemas/FooResLookupGetRQ.xsd'/>
<xsd:import namespace='http://www.opentravel.org/OTA/2003/05/betars' schemaLocation='./schemas/FooResLookupGetRS.xsd'/>
</xsd:schema>
</types>
<message name='ResLookupGetRQ'>
<part element='rq:FooResLookupGetRQ' name='FooResLookupGetRQ'></part>
</message>
<message name='ResLookupGetRS'>
<part element='rs:FooResLookupGetRS' name='FooResLookupGetRS'></part>
</message>
推荐答案
感谢@Petru Gardea 的帮助,我最终能够通过省略 -p com.generated
包规范来解决这个问题到wsimport.所以这就是我最终能够解决这个问题的方法:
Thanks to the help of @Petru Gardea I was able to eventually get past this by omitting the -p com.generated
package specification to wsimport. So this is what I was eventually able to run to get past this problem:
wsimport ./bwWsdl.xml -Xnocompile -d ../src -extension -keep -XadditionalHeaders -B-XautoNameResolution
原因是 wsimport
试图在同一个包中生成具有相同名称和/或方法的类,这显然是做不到的.
The reasoning for it is wsimport
is trying to generate classes in the same package with the same name and/or methods, which it obviously cannot do.
因此,通过省略强制包声明,wsimport
能够将类放入它想要的任何包中,结果证明每个 <xsd:schema> 是 3 个不同的包.
WSDL 中的定义.
So by omitting the forced package declaration, wsimport
is able to put the classes in whatever packages it wants, which turns out to be 3 different packages per the <xsd:schema>
definition in the WSDL.
再次感谢@Petru!
Thanks again @Petru!
这篇关于wsimport - 两个声明导致冲突,给出相同的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!