微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从其他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文件的部分?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。