加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:45:56 所属栏目:百科 来源:网络整理
导读:我有两个WSDL文件. 我正在尝试在complexType元素中的另一个WSDL文件中使用一个WSDL类型中定义的元素. 为此,我使用import元素包含了另一个WSDL文件(otherfile.wsdl在同一个文件夹中). 此外,我设置名称空间并使用ref属性(加上名称空间)来引用其他WSDL文件中的
我有两个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文件的部分?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读