1

我们正在创建一个企业级 XSD 结构来处理我们系统中的常见元素。例如,我们有以下复杂类型:

<xs:complexType name="Person">
    <xs:attribute name="First" type="xs:string" />
    <xs:attribute name="Last" type="xs:string" />
</xs:complexType>

从这种复杂类型中,我们得出以下两个元素:

<xs:element name="Employee">
    <xs:extension base="Person" />
    <xs:attribute name="SSN" type="xs:string" />
</xs:element>

<xs:element name="Customer">
    <xs:extension base="Person" />
    <xs:attribute name="CustomerID" type="xs:integer" />
</xs:element>

我们希望有一个 SOA 服务,它将绑定到“Person”的复杂类型,而不是像“Employee”或“Customer”这样的具体实现。本质上,我们希望将 SOA 输入作为多态对象而不是具体实现来处理。

有没有办法将 BPEL WSDL 绑定到抽象类型而不是具体元素?

4

1 回答 1

0

XML 模式 complexType 元素

摘要
可选。指定是否可以在实例文档中使用复杂类型。True 表示元素不能直接使用这种复杂类型,而必须使用从这种复杂类型派生的复杂类型。默认为假。参考

XML 模式扩展元素

扩展元素扩展了现有的 simpleType 或 complexType 元素。参考

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="yourNameSpace"
    xmlns="yourNameSpace" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="Person" abstract="true">
        <xs:attribute name="First" type="xs:string"/>
        <xs:attribute name="Last" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="Employee">
        <xs:complexContent>
            <xs:extension base="Person">
                <xs:attribute name="SSN" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="Customer">
        <xs:complexContent>
            <xs:extension base="Person">
                <xs:attribute name="CustomerID" type="xs:integer"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

</xs:schema>

Oracle SOA Web 服务不将抽象类型识别为可用类型。

XML Schema 任何元素

any 元素使作者能够使用模式未指定的元素来扩展 XML 文档。参考

请参阅命名空间属性以添加限制。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="yourNameSpace"
    xmlns="yourNameSpace" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="Person" type="Person"/> 
    <xs:complexType name="Person">
        <xs:sequence>
            <xs:any minOccurs="0" namespace="##targetNamespace"/>
        </xs:sequence>
        <xs:attribute name="First" type="xs:string"/>
        <xs:attribute name="Last" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="Employee">
        <xs:attribute name="SSN" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="Customer">
        <xs:attribute name="CustomerID" type="xs:integer"/>
    </xs:complexType>
</xs:schema>
于 2014-09-18T20:05:02.333 回答