重新定义 xsd 元素抛出 "not well formed" 错误

redefine xsd element throws "not well formed" error

我正在尝试在 xsd 中使用元素重新定义。我尝试了不同的组合,但似乎仍未解决此错误。当我尝试将包含重新定义的模式的 WSDL 加载到 SOAP UI 时,出现错误。此外,它不会出现在 eclipse 中 xsd 的设计中。

WSDL -> 导入 TestService.xsd -> 导入 CreateTest.xsd -> 包含 CreateTestRequestType 的定义。

当我将它加载到我的 SOAP 中时UI,一切看起来都很好并且没有错误。

现在,我正在尝试在另一个名为 [=] 的 xsd 中重新定义类型 CreateTestRequestType 66=]CreateRedefineTest.xsd 并将此 xsd 导入 TestService.xsd (导入语句已注释,但我必须取消注释此导入并注释另一个用于测试)。但是当我将 WSDL 加载到 SOAP UI 中时,出现以下错误:

Source: null Error: URL "CreateTest.xsd" is not well-formed

编辑1: 我可以通过提供绝对路径来解决此错误。是否可以使其与相对路径一起使用?

EDIT2 我查看了有关此元素的 w3 文章,该示例确实使用了相对路径。但我试图复制,但它仍然不起作用。该示例可在 this location 中找到。

我想我遗漏了一些规则,但我已经尝试了多种方法,但似乎无法解决这个问题。

下面是 WSDL 和 XSD 的源代码。

WSDL:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
 xmlns:test="http://test.com/TESTServices/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:tes="http://test.com/TestService/Test/"
 name="TestService"
 targetNamespace="http://test.com/TESTServices/">

 <wsdl:types>
  <xsd:schema targetNamespace="http://test.com/TestService/Test/">
   <xsd:include schemaLocation="TestService.xsd" />
  </xsd:schema>
 </wsdl:types>
 
 <!-- Create Test -->
 <wsdl:message name="CreateTestRequest">
  <wsdl:part element="tes:CreateTestRequest" name="parameters" />
 </wsdl:message>
 <wsdl:message name="CreateTestResponse">
  <wsdl:part element="tes:CreateTestResponse" name="parameters" />
 </wsdl:message>

 <wsdl:message name="TESTHeader">
  <wsdl:part name="request_header" element="tes:testHeader"/>
 </wsdl:message>

 <wsdl:message name="TestFault">
  <wsdl:part name="testFault" element="tes:testFault"></wsdl:part>
 </wsdl:message>


 <wsdl:portType name="TestServices_v4_0">
  <!-- Create Party -->
  <wsdl:operation name="CreateTest">
   <wsdl:input message="test:CreateTestRequest" />
   <wsdl:output message="test:CreateTestResponse" />
   <wsdl:fault name="fault" message="test:TestFault"></wsdl:fault>
  </wsdl:operation>
 </wsdl:portType>

 <wsdl:binding name="TestServicesSOAP_v4_0" type="test:TestServices_v4_0">
  <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
  
  <!-- Create Party -->
  <wsdl:operation name="CreateTest">
   <soap:operation soapAction="http://firstniagara.com/PartyService/CreateTest" />
   <wsdl:input>
    <soap:header message="test:TESTHeader" part="request_header"
     use="literal" />
    <soap:body use="literal" />
   </wsdl:input>
   <wsdl:output>
    <soap:header message="test:TESTHeader" part="request_header"
     use="literal" />
    <soap:body use="literal" />
    
   </wsdl:output>
   <wsdl:fault name="fault">
    <soap:fault name="fault" use="literal" />
   </wsdl:fault>
  </wsdl:operation>
 </wsdl:binding>

 <wsdl:service name="TestServices_v4_0">
  <wsdl:port binding="test:TestServicesSOAP_v4_0" name="TestServicesSOAP">
   <soap:address location="http://localhost/TEST/ESB" />
  </wsdl:port>
 </wsdl:service>
</wsdl:definitions>

此 WSDL 导入 TestService.xsd,其中包含以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema 
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:ct="http://test.com/TestService/CreateTest/"
 targetNamespace="http://test.com/TestService/Test/"
 elementFormDefault="qualified">

 <xsd:import namespace="http://test.com/TestService/CreateTest/" schemaLocation="CreateTest.xsd" />

<!--  <xsd:import namespace="http://test.com/TestService/CreateTest/" schemaLocation="CreateRedefineTest.xsd" /> -->
 
 <!-- CreateParty -->
 <xsd:element name="CreateTestRequest" type="ct:CreateTestRequestType" />
 <xsd:element name="CreateTestResponse" type="ct:CreateTestResponseType" />

 <xsd:element name="testHeader" type="xsd:string" />
 <xsd:element name="testFault" type="xsd:string" />
 
 
 
</xsd:schema>

TestService.xsd包含CreateTest.xsd,其中包含下面的代码并且定义了类型 CreateTestRequestType

<xsd:schema 
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 targetNamespace="http://test.com/TestService/CreateTest/"
 elementFormDefault="qualified">
 

 <!--  Create Test-->
 <xsd:complexType name="CreateTestRequestType">
  <xsd:sequence>
   <xsd:element name="RequestId" type="xsd:string" minOccurs="1"/>
   <xsd:element name="TestRecord" type="xsd:string" minOccurs="1" />
  </xsd:sequence>
 </xsd:complexType>
 <xsd:complexType name="CreateTestResponseType">
  <xsd:sequence>
   <xsd:element name="RequestId" type="xsd:string" minOccurs="1"/>
   <xsd:element name="Messages" type="xsd:string" minOccurs="0"/>
   <xsd:element name="TestIdentifier" type="xsd:string" minOccurs="0"/>   
  </xsd:sequence>
 </xsd:complexType>
 
</xsd:schema>

正在尝试重新定义 CreateRedefineTest.xsd 中的 CreateTestRequestType,如下所示:

<xsd:schema 
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:cp="http://test.com/TestService/CreateTest/"
 targetNamespace="http://test.com/TestService/CreateTest/"
 elementFormDefault="qualified">
 
  <xsd:redefine schemaLocation="CreateTest.xsd">
  <xsd:complexType name="CreateTestRequestType">
    <xsd:complexContent>
      <xsd:extension base="cp:CreateTestRequestType">
        <xsd:sequence>
          <xsd:element name="country" type="xsd:string"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:redefine> 

</xsd:schema>

这可能是因为您的解析器无法找到 "cp:http://test.com/TestService/CreateTest/" 的架构文档。 如果您对 cp xsd 使用绝对 URL 或使用 XML 目录,这是否仍然会发生?

SoapUI 是一个很棒的工具,它帮助我度过了难关,并将在未来继续以出色的方式帮助我。

我认为这是许多用户显然不使用的功能之一,而且似乎是 SoapUI 5.0.0 中的一个错误。我在几个旧版本的 SoapUI 中尝试了同样的事情并得到了相同的结果。我还在 SOAP UI NG Pro 1.2.2.

的试用版中尝试过

然后我在 XMLSpy 中尝试了这个,它没有任何错误地工作,与 xsd 完全相同,没有任何修改。 (注意:TestService.xsd 需要 Redefined.xsd 的注释导入语句)

我还发现报告了一个错误,但没有找到解决方案或关于该解决方案的任何评论。如果有人想要这些错误的参考,location。如果您愿意,可以查找相关的错误 651、586 和 539。

我希望 SoapUI 中的某个时候可以修复此错误。 我还创建了一个新的bug来引用这些旧的bug并合并:SourceForge 671

希望这 post 可以节省其他人的时间,如果他们 运行 遇到同样的问题。

感谢所有看过这篇文章的人 post。

我想确认在我的消息集中使用 SOAP UI.UI.

版本 5.0.0 的消息集中的 xsd:redefine 元素时,我遇到了同样的错误

基本上,我必须扩展另一个由开放地理空间组定义的消息集的消息定义 - Web 特征服务,并在我的 WSDL 的请求和响应定义中使用重新定义的模式。

除了'not well-formed'错误,我还得到:

'Source: null Error: type 'QueryType@http://www.opengis.net/wfs' not found.'

Eclipse 的 WSDL 验证没有问题,我可以毫无问题地将它导入 Rational Service Tester (V8.5.0.2)。