Search code examples
asp.netweb-servicesjax-wsapache-axisjava-metro-framework

Web Services interoperability - wsdl complex type extension


Let's say we have a Web Service that use WSDL complex type extensions. Consider the (valid WSDL) example below where Vechicle is abstract. Two types, Car and Bike, inherit from it:

<xs:complexType name="Vehicle" abstract="true">
  <xs:sequence>
    <xs:element name="common1" type="xs:string" minOccurs="0"/>
    <xs:element name="common2" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="Car">
  <xs:complexContent>
    <xs:extension base="tns:Vehicle">
      <xs:sequence>
        <xs:element name="carValue1" type="xs:string" minOccurs="0"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
<xs:complexType name="Bike">
  <xs:complexContent>
    <xs:extension base="tns:Vehicle">
      <xs:sequence>
        <xs:element name="bikeValue1" type="xs:string" minOccurs="0"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

and a type Transport that uses the Vehicle type as one its elements:

<xs:complexType name="Transport">
  <xs:sequence>
      <xs:choice>
        <xs:element ref="tns:Car"/>
        <xs:element ref="tns:Bike"/>
      </xs:choice>
    <xs:element name="description" type="xs:string"/>
</xs:sequence>
</xs:complexType>

Note that Vehicle is not itself a possible type inside Transport and that's of course because Vehicle is abstract. Pretty easy to generate the above in Java Metro stack. Blaise Doughan's blogs gave me some valuable input here.

My question is how this will work in terms of web service interoperability, in particular in relation to WS-I Basic Profile. Can I be sure that WS-I compliant web service frameworks will be able to consume such web service?. I understand that WS-I basically only specifies a subset of what is allowed in WSDL as such. I've tried reading the WS-I specs to understand this issue but had no real luck. The language is simply too tough for me. I've found an article from 2004 which raises some concerns :

The basic reason for this concern is that the use of the extension mechanism for value object inheritance is outside of the WS-I basic profile, although not specifically excluded by it. Currently, there is no mention of using the extension construct in the WS-I basic profile and, additionally, the WS-I compliance test suite does not cover this case.

...but that was in 2004 and clearly relate to WS-I Basic Profile v1.0. Since then WS-I Basic profile 1.1, 1.2 and 2.0 specs have been released.

So the question is : Will web services that use the WSDL value type extension feature (i.e <xs:complexType name="xxx" abstract="true"> and <xs:extension base="xxx">) work in all frameworks that claim to be WS-I Basic Profile compliant? Can they consume such web service?


Solution

  • WS-I Basic Profile says the following about the xml:

    The Profile uses Web Services Description Language (WSDL) to enable the description of services as sets of endpoints operating on messages. This section of the Profile incorporates the following specifications by reference (...): XML Schema Part 1: Structures

    So it references the XML Schema as something it is based on. In there, you'll find:

    Abstract complex types can be used as {base type definition}s, or even as the {type definition}s of element declarations, provided in every case a concrete derived type definition is used for ·validation·, either via xsi:type (§2.6.1) or the operation of a substitution group.

    Furthermore, it defines the construction <extension base="QName"> about which the document has a lot to say.

    But all this is on a conceptual level, not necessarily directly relating it to object inheritance. While it's probably not too difficult to make such a mapping (and your link exactly show that), it is also not strictly defined. I guess that's what they talk about when raising the concerns.

    So technically and syntactically, the construction is part of the standard, but the implementation might handle it in unforeseen ways. On the other hand, a tool adhering the standard, should be able to both accept and output valid WS-I XML, and perform validation as also specified in the XML standard.

    To conclude, I'd say that any tool not able to handle your construction somehow, is not a valid WS-I implementation.