WSDL - Interface Inheritance and Extension in WSDL 2.0

 

1. Introduction

Web Services Description Language (WSDL) 2.0 is an XML-based language used to describe the functionality of a web service and how clients can communicate with it. A WSDL document defines the operations offered by a service, the messages exchanged, the data types used, and the communication mechanisms supported.

In large applications, multiple web services often share similar operations. For example, an online shopping application may have customer services, order services, and payment services. Several of these services might need common operations, such as retrieving information, checking a status, or validating a request.

Instead of defining similar operations repeatedly in every service, WSDL 2.0 provides interface inheritance and extension. This feature allows one interface to reuse the operations of another interface and add new operations when necessary.

Interface inheritance improves code organization, reduces duplication, and makes service contracts easier to maintain.

2. What Is an Interface in WSDL 2.0?

An interface in WSDL 2.0 describes the operations that a web service makes available to its clients. It defines what a service can do without necessarily specifying the complete details of how those operations are implemented.

An interface typically includes:

  • Operations: Actions that clients can request from the service.

  • Input messages: Information sent by a client to invoke an operation.

  • Output messages: Information returned by the service.

  • Fault messages: Error information that may be returned when an operation fails.

For example, a library service may provide the following operations:

  • searchBook — searches for a book.

  • getBookDetails — retrieves information about a book.

  • checkAvailability — checks whether a book is available.

These operations can be grouped into a single WSDL interface called LibraryInterface.

The interface serves as a contract between the service provider and its clients. Clients can use this contract to understand the available operations without needing to know the internal implementation of the service.

3. What Is Interface Inheritance?

Interface inheritance is a mechanism through which one interface obtains the operations defined by another interface.

In WSDL 2.0, an interface can extend another interface using the extends attribute. The interface that is extended is called the parent interface, while the interface that extends it is called the child interface.

The child interface inherits the operations of the parent interface and can define additional operations of its own.

For example, consider an application that provides basic customer services and premium customer services.

The basic customer interface may provide:

  • getCustomerDetails

  • updateCustomerDetails

A premium customer interface may need all these operations along with additional functionality, such as:

  • getRewardPoints

  • viewExclusiveOffers

Instead of redefining the basic customer operations, the premium interface can extend the basic interface.

The resulting premium interface includes all inherited operations and its additional operations.

This approach is useful when several services share a common set of capabilities but require different specialized features.

4. How Interface Extension Works in WSDL 2.0

Interface extension works by establishing a relationship between two interfaces.

The parent interface defines common operations. The child interface references the parent through its extends attribute and introduces additional operations where required.

The following steps explain the process.

Step 1: Define the parent interface.

Create an interface containing the operations that should be shared by multiple services. For example, a CustomerInterface can define operations for retrieving and updating customer details.

Step 2: Define the child interface.

Create another interface for a specialized service. For example, a PremiumCustomerInterface can extend CustomerInterface.

Step 3: Specify the inheritance relationship.

Use the extends attribute to identify the parent interface. The value refers to the parent interface by its qualified name.

Step 4: Add specialized operations.

Define any additional operations required by the child interface, such as retrieving reward points or accessing premium offers.

Step 5: Implement the service contract.

The service implementation must support the operations required by the resulting interface, including the inherited operations and the additional operations.

This structure allows common functionality to be defined once and reused in multiple service interfaces.

5. Example of Interface Inheritance in WSDL 2.0

Consider an online shopping system with a basic product service and an advanced product service.

The basic product service provides operations for retrieving product information. The advanced product service extends this interface to provide additional product management functionality.

The following example illustrates the concept.

<?xml version="1.0" encoding="UTF-8"?>

<description
    xmlns="http://www.w3.org/ns/wsdl"
    xmlns:tns="http://example.com/products"
    xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
    targetNamespace="http://example.com/products"
    name="ProductService">

    <interface name="BasicProductInterface">

        <operation
            name="getProductDetails"
            pattern="http://www.w3.org/ns/wsdl/in-out">

            <input
                element="tns:GetProductDetailsRequest"/>

            <output
                element="tns:GetProductDetailsResponse"/>

        </operation>

    </interface>

    <interface
        name="AdvancedProductInterface"
        extends="tns:BasicProductInterface">

        <operation
            name="updateProductPrice"
            pattern="http://www.w3.org/ns/wsdl/in-out">

            <input
                element="tns:UpdateProductPriceRequest"/>

            <output
                element="tns:UpdateProductPriceResponse"/>

        </operation>

    </interface>

</description>

This is an illustrative interface fragment, not a complete deployable service description. The referenced XML elements and any required message type definitions, bindings, and service declarations must also be supplied in a complete WSDL document.

Explanation of the example

The BasicProductInterface defines the getProductDetails operation. A client can use this operation to request information about a particular product.

The AdvancedProductInterface contains the following attribute:

extends="tns:BasicProductInterface"

This attribute establishes the inheritance relationship. The prefix tns refers to the target namespace declared in the document.

As a result, AdvancedProductInterface incorporates the operation defined by BasicProductInterface and adds the updateProductPrice operation.

The advanced interface therefore offers two operations:

  1. getProductDetails, inherited from the basic interface.

  2. updateProductPrice, defined directly in the advanced interface.

The example demonstrates how interface extension supports reuse without requiring the same operation definition to be copied into multiple interfaces.

6. Difference Between Interface Inheritance and Interface Extension

The terms inheritance and extension are closely related in WSDL 2.0.

Interface inheritance describes the relationship in which a child interface receives the operations of a parent interface.

Interface extension is the mechanism used to establish that relationship in the WSDL document, through the extends attribute.

For example, if PremiumAccountInterface extends AccountInterface, the premium account interface inherits the operations of the account interface and can introduce premium-specific operations.

Interface extension does not mean that the child interface automatically inherits the parent's complete implementation or its runtime configuration. It concerns the service contract and the operations defined by that contract.

7. Advantages of Interface Inheritance and Extension

7.1 Reusability

Common operations can be defined once in a parent interface and reused by multiple child interfaces. This reduces repeated definitions and simplifies the organization of service descriptions.

7.2 Reduced duplication

Without interface extension, developers may need to declare the same operations in several interfaces. Repeating these definitions increases the possibility of inconsistencies. Inheritance provides a shared definition for common operations.

7.3 Easier maintenance

When a shared interface changes, developers can manage the common operation definitions in one place. However, changes to a parent interface must still be checked against all dependent interfaces and clients.

7.4 Better organization

Interfaces can be arranged according to common and specialized responsibilities. For example, a banking system can define a basic account interface and extend it for savings accounts, current accounts, or business accounts.

7.5 Improved consistency

Services that extend the same parent interface share a common set of operation definitions. This encourages consistency across related services and makes service contracts easier for clients to understand.

7.6 Support for modular service design

Large applications can divide their functionality into reusable interfaces. Each interface can focus on a specific responsibility, while specialized interfaces can combine shared operations with additional capabilities.

8. Limitations and Important Considerations

Although interface inheritance is useful, it must be designed carefully.

Dependency between interfaces: A child interface depends on the parent interface. Changes to the parent may affect every interface that extends it.

Operation compatibility: Developers must ensure that inherited and additional operations form a coherent service contract and that implementations support the required operations.

Namespace management: WSDL uses XML namespaces to distinguish interface names and other definitions. Qualified names must reference the correct namespace.

Avoiding unnecessary inheritance: Creating too many levels of interface extension can make service contracts difficult to understand. Inheritance should be used when interfaces genuinely share common operations.

Implementation requirements: Defining an interface in WSDL does not automatically implement the service. The application must provide the actual behavior for the declared operations.

Tool support: Developers should verify that their WSDL processors, frameworks, and service-generation tools support the WSDL 2.0 features they intend to use.

9. Real-World Applications

Interface inheritance and extension can be useful in many types of web services.

E-commerce systems: A common product interface can define operations for retrieving product information, while specialized interfaces add inventory updates, pricing management, or product administration.

Banking applications: A general account interface can define common account operations. Specialized interfaces can extend it with services for savings accounts, loans, or business accounts.

Healthcare systems: A basic patient interface can define operations for retrieving patient details, while specialized interfaces add appointment management or medical-record retrieval.

Educational platforms: A general student interface can define operations for viewing student information, while specialized interfaces add attendance reports, examination results, or course registration.

Enterprise applications: Common interfaces can define standard operations used across departments, while specialized interfaces introduce the additional capabilities required by particular business units.

In each case, the objective is to reuse common service definitions while keeping specialized functionality separate.

10. Difference Between WSDL 1.1 and WSDL 2.0 in Interface Extension

WSDL 1.1 and WSDL 2.0 differ in their terminology and structural approach.

Feature

WSDL 1.1

WSDL 2.0

Main abstract component

portType

interface

Direct interface extension using extends

Not provided as a standard portType feature

Supported

Reuse of common operations

Often achieved through shared definitions, tools, or design conventions

Can be expressed through interface inheritance

Service description approach

Uses messages, portType, bindings, and services

Uses interfaces, bindings, and services with a revised component model

WSDL 1.1 does not provide the same standard interface inheritance mechanism as WSDL 2.0. Developers working with WSDL 1.1 may use other approaches to reuse definitions, but these should not be confused with WSDL 2.0's interface extension mechanism.

Conclusion

Interface inheritance and extension in WSDL 2.0 provide a structured way to reuse web service operations. By defining common operations in a parent interface and extending that interface to introduce specialized operations, developers can reduce duplication and create more maintainable service contracts.

The extends attribute establishes the relationship between interfaces, allowing a child interface to incorporate the operations of its parent. When applied carefully, this feature supports modular service design, consistency, and easier maintenance in applications that expose multiple related web services.