1

我们正在尝试使用由第三方托管的 Web 服务。当我尝试使用 wsimport 生成 artifcats 和 JAXB 类时,我遇到了以下错误。请注意,这两个 xsd 文件内容完全相同(不知道为什么会这样做),包括名称空间。但是最后一部分 servdocoid 是不同的。wsdl 和 schema 的结构将遵循。

[ERROR] 'ElementX' is already defined
  line # of http:/....:port/wsdl/schema1.xsd?serviceoid=123&servdocoid=<b>5</b>

[ERROR] (related to above error) the first definition appears here
  line # of http:/....:port/wsdl/schema1.xsd?serviceoid=123&servdocoid=<b>1</b>

我想我知道问题出在哪里,我正在尝试找到一种解决方法,将 `-catalog 与 wsimport 一起使用(不确定这是否是正确的做法),但仍然会出错。

wsdl 结构如所述,我只突出显示了关键部分,忽略了 wsdl 定义的其余部分

<wsdl:definitions targetNamespace="http:/xyz.com" xmlns:soap12="http:/schemas.xmlsoap.org/wsdl/soap12/ xmlns:wsdl="http:/schemas.xmlsoap.org/wsdl/" xmlns:xsd="http:/www.w3.org/2001/XMLSchema">
...
<!-- relevant -->
<xsd:schema targetNamespace="http://schema1" xmlns:wsdl="http:/schemas.xmlsoap.org/wsdl/" xmlns:xsd="http:/www.w3.org/2001/XMLSchema xmlns:soap12="http:/schemas.xmlsoap.org/wsdl/soap12/>
  <xsd:include schemaLocation="http:/domain.com:port/wsdl/schema1.xsd?serviceoid=123&servdocoid=1" />
</xsd:schema>
...............
</wsdl:definitions>

上面 wsdl 中使用的模式是嵌套的,这意味着它反过来导入多个模式,这些模式又可以导入多个模式。假设它是一个链条。

schema1.xsd

<xsd:schema elementFormDefault="qualified" targetNamespace="http:/schema1" xmlns:tns1="http:/schema1" xmlns:tns2="http:/schema2" xmlns:tns3="http:/schema3" xmlns:xsd="http:/www.w3.org/2001/XMLSchema">
....
<!-- relevant -->
<xsd:import namespace="http:/schema2" schemaLocation="http:/domain.com:port/wsdl/schema2.xsd?serviceoid=123&servdocoid=2" /> 
  <xsd:import namespace="http://schema3" schemaLocation="http:/domain.com:port/wsdl/schema3.xsd?serviceoid=123&servdocoid=3" /> 
...
</xsd:schema>

schema2.xsd

<xsd:schema elementFormDefault="qualified" targetNamespace="http:/schema2" xmlns:tns2="http:/schema2" xmlns:tns4="http://schema4"  xmlns:xsd="http:/www.w3.org/2001/XMLSchema">
...
<!-- relevant -->
 <xsd:import namespace="http:/schema4" schemaLocation="http:/domain.com:port/wsdl/schema4.xsd?serviceoid=123&servdocoid=4" /> 
...
</xsd:schema>

schema4.xsd

<xsd:schema elementFormDefault="qualified" targetNamespace="http:/schema4" xmlns:tns4="http:/schema2" xmlns:tns1="http:/schema1"  xmlns:xsd="http:/www.w3.org/2001/XMLSchema">
...
<!-- relevant -->
 <xsd:import namespace="http:/schema1" schemaLocation="http:/domain.com:port/wsdl/schema1.xsd?serviceoid=123&servdocoid=5" /> 
...
</xsd:schema>

所以这里的关键模式是 schema1.xsd 和 schema4.xsd。两者具有完全相同的内容,但具有不同的链接。话虽如此,我正在尝试使用 -catalog 文件让 wsimport 知道对于所有命名空间“http:/schema1”始终解析为一个链接 http:/domain.com:port/wsdl/schema1.xsd?serviceoid =123&servdocoid=1 但我仍然无法让它工作。

4

0 回答 0