小编use*_*231的帖子

从其他 WSDL 文件引用 xml 架构元素

我有两个 WSDL 文件。我正在尝试在复杂类型元素中的另一个 WSDL 文件中使用在一种 WSDL 类型中定义的元素。

为此,我使用导入元素包含了另一个 WSDL 文件(otherfile.wsdl 位于同一文件夹中)。此外,我设置了命名空间并使用 ref 属性(加上命名空间)来引用其他 WSDL 文件中的元素。

但是,它抱怨来自 othertest 命名空间的元素无法从此 test.wsdl xml 模式引用。有人知道如何解决这个问题吗?

您将在下面找到这两个文件的代码:

测试.wsdl

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:tns="http://www.example.com/test/" 
   xmlns:ot="http://www.example.com/othertest/" 
   targetNamespace="http://www.example.com/test/" >

<import namespace="http://www.example.com/othertest/" location="othertest.wsdl"/>

<types>
    <xsd:schema targetNamespace="http://www.example.com/test/">     
        <xsd:element name="ResultElement2">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element ref="ot:othertest_element" /> 
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>      
    </xsd:schema>
</types>

</definitions>
Run Code Online (Sandbox Code Playgroud)

其他测试.wsdl

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:tns="http://www.example.com/othertest/" 
   targetNamespace="http://www.example.com/othertest/" >

<types>
    <xsd:schema targetNamespace="http://www.example.com/othertest/">
        <xsd:element name="othertest_element">
            <xsd:simpleType>
                <xsd:restriction base="xsd:int"/>
            </xsd:simpleType>
        </xsd:element>      
    </xsd:schema>
</types>

</definitions>  
Run Code Online (Sandbox Code Playgroud)

xml import wsdl ref

5
推荐指数
1
解决办法
7878
查看次数

标签 统计

import ×1

ref ×1

wsdl ×1

xml ×1