【问题标题】:Referencing ComplexType Elements within ComplexType/Sequence Elements in XSD在 XSD 中的 ComplexType/Sequence 元素中引用 ComplexType 元素
【发布时间】:2013-01-16 11:57:01
【问题描述】:

我正在尝试构建一个 xsd 文件(在 WSDL 中)以从 SOAP 请求中获取数据。我有预期的肥皂请求:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
    <m:upsertEntity xmlns:m="http://www.boomi.com/connector/wss">
        <eTimeRequest>
            <ObjectType>String</ObjectType>
            <Action>String</Action>
            <eTimeID>String</eTimeID>
            <OperativeID>String</OperativeID>
        </eTimeRequest>
    </m:upsertEntity>
</SOAP-ENV:Body>

这是我尝试过的。您不能在另一个中拥有&lt;xs:ComplexType&gt;。我已经尝试过引用方法,但显然,当我尝试使用它进行 SOAP 请求时,它是无效的。我能做什么?

这是 WSDL 中的 XSD:

    <xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss">
        <xs:element name="eTimeRequest" type="eTimeRequest"/>
        <xs:complexType name="eTimeRequest">
            <xs:sequence>
                <xs:element maxOccurs="1" minOccurs="0" name="ObjectType" type="xs:string"/>
                <xs:element maxOccurs="1" minOccurs="0" name="Action" type="xs:string"/>
                <xs:element maxOccurs="1" minOccurs="0" name="eTimeID" type="xs:string"/>
                <xs:element maxOccurs="1" minOccurs="0" name="OperativeID" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>

        <xs:element name="upsertEntity" type="tns:upsertEntity"/>
        <xs:complexType name="upsertEntity">
            <xs:sequence>
                <xs:element minOccurs="0" type="eTimeRequest"/> <!-- These should be the ObjectType, Action, eTimeID and OperativeID in here -->
            </xs:sequence>
        </xs:complexType>

    </xs:schema>

编辑 我在链接的代码中注意到的另一件事是我使用了Type="eTimeRequest" 而不是ref="eTimeRequest"。无论如何,仍然无效。这是我在验证时收到的错误消息:

无效的 XML 架构:“eTimeRequest”必须引用现有元素。

【问题讨论】:

    标签: soap xsd wsdl complextype


    【解决方案1】:

    对那些读过这篇文章的人感到抱歉。我显然在我的 XSD 代码中犯了一个错误,这样做是浪费时间。

    是的,&lt;xs:ComplexType&gt;&lt;xs:ComplexType&gt;不允许,但在&lt;xs:ComplexType&gt; 中包含&lt;xs:ComplexType&gt;&lt;xs:Element&gt; 允许。因此,生成的原始 SOAP 请求无效。我通过我们的系统运行了新版本,它运行正常。

    WSDL 中正确的 XSD 架构应该是:

    <xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss">
        <xs:element name="upsertEntity" type="tns:upsertEntity"/>           
        <xs:complexType  name="upsertEntity">
            <xs:sequence>
                <xs:element name="eTimeRequest">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element maxOccurs="1" minOccurs="0" name="ObjectType" type="xs:string"/>
                            <xs:element maxOccurs="1" minOccurs="0" name="Action" type="xs:string"/>
                            <xs:element maxOccurs="1" minOccurs="0" name="eTimeID" type="xs:string"/>
                            <xs:element maxOccurs="1" minOccurs="0" name="OperativeID" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>           
    </xs:schema>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-24
      • 1970-01-01
      • 2019-07-28
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 2012-06-06
      • 2011-09-15
      相关资源
      最近更新 更多