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

我有两个WSDL文件.
我正在尝试在complexType元素中的另一个WSDL文件中使用一个WSDL类型中定义的元素.

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

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

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

test.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>

othertest.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>

解决方法

我有部分解决方案.似乎当我在xsd文件中定义元素/类型而不是WSDL文件时,使用< xsd:import namespace =“...”schemaLocation =“...”/>导入此文件.在< xsd:schema>内< types>的元素,它不会抱怨命名空间.但是,只要我再次导入wsdl文件(将类型和元素包含在< types>中),它就会再次开始抱怨命名空间.

但是,仍然存在一个问题,即我提供的是wsdl文件而不是xsd文件.有没有办法重用wsdl文件中定义的元素/类型与< types>另一个wsdl文件的部分?

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念