簡體   English   中英

無法引用另一個架構:無法將名稱“xs:架構”解析為(n)“元素聲明”組件

[英]Unable to ref to another schema: Cannot resolve the name 'xs:schema' to a(n) 'element declaration' component

我參考了指南,根據現有的 wsdl 文件重新創建了 SOAP 網絡服務: https://www.baeldung.com/spring-boot-service 原始的 wsdl 位於 .NET 環境中,而我需要使用 Z91F54BF487C7FFB683 webservice 從 Java 環境重現相同的響應。

對於返回簡單數據類型(例如 int)的簡單響應,我沒有任何問題。 但是對於返回 DataSet(來自 .NET)的復雜響應,我無法重新創建正確的類。 它可能與 eclipse 工作區中遇到的以下錯誤有關:

在此行找到多個注釋:- src-resolve:無法將名稱“xs:schema”解析為(n)“元素聲明”組件。 - src-resolve.4.2:解析組件“xs:schema”時出錯。 檢測到“xs:schema”在命名空間“http://www.w3.org/2001/XMLSchema”中,但該命名空間中的組件不能從模式文檔“file:///C:/03_PROJECTS/”中引用ws/src/main/resources/schema/abc.xsd'。 如果這是不正確的命名空間,則可能需要更改“xs:schema”的前綴。 如果這是正確的命名空間,則應將適當的“import”標記添加到“file:///C:/03_PROJECTS/ws/src/main/resources/schema/abc.xsd”。

下面是 xsd 文件的架構詳細信息:

<xs:schema elementFormDefault="qualified" targetNamespace="http://www.example.net/abc/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

下面是出現錯誤的示例截圖元素:

<xs:element name="GetProdItemDescriptionsResponse">
<xs:complexType>
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1"
            name="GetProdItemDescriptionsResult">
            <xs:complexType>
                <xs:sequence>
                    <xs:element ref="xs:schema"/>
                    <xs:any />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>

請告知為什么引用另一個模式會引發錯誤。 我相信對此的響應應該是之前提到的 DataSet。 只是想知道 xsd 文件是否存在問題,或者在 Java 中是否可行,或者是否有可能的解決方法。

您的 XSD 文件包含引用XSD 模式的元素引用。 這很不尋常,但並沒有錯。 元素內容似乎是 XML 模式的片段。 我懷疑您需要在 XSD 文件中添加一個<xs:import> ,以便它可以找到描述 XSD 的 XSD。

可以這樣做:

  • 從 W3C web 站點下載“架構的架構”
  • schemaLocation屬性添加到 XSD 作為 XML 處理器的提示

However, you should be able to add an 'entity resolver' in your Spring environment which will allow the Spring XML processor to locate the XSD via its URL.

在您問之前...我不知道為什么.Net 沒有報告此錯誤,但.Net 可能會自動解析 schema-for-schema。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM