The Virtuoso SOAP server implements handling of inherited XSD types. The simple example of such relation between types can be explained as

   Type  A, also know as the 'base' type,
   and type B an extension of A.
   +---+   +---+
   | a |-->

| c |
   | b |   | d |
   +---+   +---+

   which can be defined by two separate types without relation

   A type   B type
   +---+   +---+
   | a |   | a |
   | b |   | b |
   +---+   +- -+
           | c |
           | d |

But when type A has changed, type B will not be changed in second representation. This is because B is not a relative to A per se.

To work in such situations Virtuoso SOAP server handles extensions to XSD types as follows:

  1. each type and base type have defined a User Defined SQL type (UDT).

  2. the XSD types defined for SOAP processing are defined with UDT relation (see soap_dt_define)

  3. the inheritance is declared with 'extension' element in XSD type declaration

When we have these preliminaries the WSDL will declare in 'schema' part of WSDL all depending types. Furthermore the SOAP processor will handle inherited members of derived types.

Example 17.2. Declaration and usage of depending types

Consider the following XSD and User Defined Type declaration for a base type 'BaseStruct':

        <!-- XSD type declaration, file base.xsd -->

        <complexType name="BaseStruct">
                        <element name="floatMessage" type="xsd:float"/>
                        <element name="shortMessage" type="xsd:short"/>

        -- corresponding user defined sql type
        create type DB.DBA.BaseStruct as (floatMessage real, shortMessage int __soap_type 'short');

Furthermore we are extending the BaseStruct with adding three more elements (members) with declaration of ExtendedStruct:

        <!-- XSD type declaration, file ext.xsd -->

        <complexType name="ExtendedStruct">
                        <extension base="tns:BaseStruct">
                                        <element name="stringMessage" type="xsd:string"/>
                                        <element name="intMessage" type="xsd:int"/>
                                        <element name="anotherIntMessage" type="xsd:int"/>

        -- corresponding user defined SQL type
       create type DB.DBA.ExtendedStruct under DB.DBA.BaseStruct as (
            stringMessage nvarchar __soap_type 'string',
            intMessage int __soap_type 'int',
            anotherIntMessage int __soap_type 'int');

Once we are done with declarations as XSD files and user defined SQL types, we must register them as SOAP types for processing:

SQL> soap_dt_define ('', file_to_string ('base.xsd'), 'DB.DBA.BaseStruct');
SQL> soap_dt_define ('', file_to_string ('ext.xsd'), 'DB.DBA.ExtendedStruct');

Now we are able to create a PL procedure to use as a SOAP method, which simply will accept an ExtendedStruct and echo it back to the client.

create procedure
echoExtendedStruct (in param DB.DBA.ExtendedStruct __soap_type '')
returns DB.DBA.ExtendedStruct __soap_type ''
  --  All members  of DB.DBA.ExtendedStruct and DB.DBA.BaseStruct are available in param.
  return param;

grant execute on echoExtendedStruct to SOAP;

The SOAP request to that method will be as follows:

<SOAP-ENV:Envelope xmlns:SOAP-ENV=""
    <m:echoExtendedStruct xmlns:m="">
      <param xsi:type="m0:ExtendedStruct">
        <floatMessage xsi:type="xsd:float">3.14159</floatMessage>
        <shortMessage xsi:type="xsd:short">4096</shortMessage>
        <stringMessage xsi:type="xsd:string">String</stringMessage>
        <intMessage xsi:type="xsd:int">0</intMessage>
        <anotherIntMessage xsi:type="xsd:int">0</anotherIntMessage>

The SOAP response to the above request will be as follows:

xmlns:ns0="" xmlns:wsdl="services.wsdl">

    <cli:echoExtendedStructResponse xmlns:cli="">
      <CallReturn xsi:type="ns0:ExtendedStruct">
        <stringMessage xsi:type="xsd:string">String</stringMessage>
        <intMessage xsi:type="xsd:int">0</intMessage>
        <anotherIntMessage xsi:type="xsd:int">0</anotherIntMessage>
        <floatMessage xsi:type="xsd:float">3.14159</floatMessage>
        <shortMessage xsi:type="xsd:short">4096</shortMessage>
[Note] Note:

Although the namespace declarations of XSD types are skipped for better readability, these must be present when declaring (see the Extending Datatypes for SOAP Objects section, discussed earlier)