Skip to content
VirtualLP Virtual Learning Platform

Web Services and WSDL Structure

15 min read Topic 3 of 34

A program can ask another program for information over a network. For example, a travel app can ask a booking service for available seats.

A web service makes this possible. WSDL stands for Web Services Description Language. It is an XML (Extensible Markup Language) description often used with SOAP (originally Simple Object Access Protocol) services. It tells another program what it can ask for, what data to send and which address to use.

restaurant waiter

You (the client) don't go into the kitchen. You read the menu (what can be ordered), tell the waiter your order in an agreed way, and the waiter brings back your food. A web service works the same way: the menu is the WSDL, the order slip is the message, and the kitchen is the service – it doesn't matter what language the cook speaks.

Web service

A web service lets programs exchange information over a network. They follow agreed message rules so that programs on different systems can work together. SOAP services commonly use WSDL descriptions; web APIs (Application Programming Interfaces) may use HTTP (Hypertext Transfer Protocol) with XML or JSON (JavaScript Object Notation).

  • Interoperable = works across different languages and systems (a Java program can call a .NET program).
  • Machine-to-machine = one program talks to another program, no human clicking.

Why web services?

Other ways for programs to communicate include CORBA (Common Object Request Broker Architecture), DCOM (Distributed Component Object Model) and Java RMI (Remote Method Invocation). CORBA supports several languages; Java RMI is designed for Java. These systems can need extra protocol and network setup.

Web services fixed this by using:

  • HTTP (Hypertext Transfer Protocol)/HTTPS (Hypertext Transfer Protocol Secure) – common web protocols, often on ports 80/443. A firewall can still block them.
  • XML / JSON – plain-text data formats that any language can read.
  • Shared specifications – W3C (World Wide Web Consortium) publishes SOAP and WSDL specifications. IETF (Internet Engineering Task Force) publishes HTTP standards. REST (Representational State Transfer) is a design style, not a protocol.
Feature CORBA / RMI Web services
Protocol IIOP (Internet Inter-ORB Protocol) / JRMP (Java Remote Method Protocol) (binary) HTTP (text)
Data format Depends on the technology Commonly XML / JSON
Network setup May need extra protocol rules Often uses web ports; access rules still apply
Language support CORBA: several languages; RMI: Java Depends on compatible tools and message formats
Coupling (how tightly joined) Tight Loose

Characteristics of web services

  1. Interoperability – a .NET client can call a Java service.
  2. Loose coupling – the client and the service only need to agree on the interface (the "menu"), nothing else. Either side can change its inner code freely.
  3. Description – a service can publish its interface, using WSDL for SOAP or an OpenAPI document for a web API.
  4. Discovery – services may be listed in a registry or catalogue. A registry is not required for every service.
  5. Standard protocols – HTTP, XML, JSON, SOAP.
  6. Reusability – one service can serve the website, the mobile app and partner companies.

Service-Oriented Architecture (SOA)

Web services are the building blocks of SOA – a way of designing software where an application is built from independent, reusable services, like assembling furniture from ready-made parts.

flowchart LR
    R[(Service Registry<br/>UDDI)]
    P[Service Provider] -- "1. Publish (WSDL)" --> R
    Q[Service Requester] -- "2. Find" --> R
    R -- "3. Returns WSDL" --> Q
    Q -- "4. Bind & invoke (SOAP/HTTP)" --> P
Role Responsibility Everyday picture
Service provider Builds the service and publishes its description (WSDL). A plumber who lists his number in the directory
Service registry (broker) Stores service descriptions so others can find them – UDDI (Universal Description, Discovery and Integration). The phone directory / Justdial
Service requester (consumer) Finds a service, reads its WSDL and calls it. You, searching the directory and calling the plumber

The three actions publish, find, bind form the classic SOA triangle – a favourite exam diagram.

The web service protocol stack

Think of it as layers, from "how do I find it" down to "how do the bytes travel":

Layer Purpose Standard
Discovery Find services UDDI
Description Describe the interface WSDL
Messaging Format of the messages SOAP, XML
Transport Carry the messages HTTP, HTTPS, SMTP, JMS
Two families of web services

SOAP-based ("big") web services wrap data in SOAP envelopes and are described by WSDL. RESTful web services use plain HTTP methods (GET, POST…) on URLs (Uniform Resource Locators) and usually send JSON. You need to know both; REST has its own lesson.

WSDL – Web Services Description Language

WSDL

WSDL (Web Services Description Language) describes a web service in XML. It lists the operations, input and output data, message rules and service address.

A WSDL file is a contract describing how to call a service. Tools can read it and generate client code called stubs. Examples are Java's wsimport and Visual Studio's Add Service Reference.

The structure of a WSDL 1.1 document

flowchart TB
    D[definitions] --> T[types<br/>XML Schema data types]
    D --> M[message<br/>input / output data]
    D --> PT[portType<br/>abstract operations]
    D --> B[binding<br/>protocol + encoding]
    D --> S[service<br/>ports = endpoint URLs]
    PT --> M
    M --> T
    B --> PT
    S --> B
Element Answers the question Contains Restaurant picture
<definitions> The root (outer box) Namespaces and all other elements The whole menu card
<types> What kinds of data are used? XML Schema (XSD (XML Schema Definition)) definitions "Quantity is a number, dish name is text"
<message> What data goes in and out? One or more <part>s The order slip and the bill
<portType> What operations exist? (abstract interface) <operation> with <input> / <output> / <fault> The list of dishes you can order
<binding> How are messages sent? Protocol (SOAP 1.1/1.2), style (document/rpc), use (literal/encoded) "Order at the counter, pay by UPI"
<service> Where is the service? <port> elements with the endpoint address (URL) The restaurant's address
Remember the order with the phrase “

Types Message PortType Binding Service” Abstract part = types + message + portType (what). Concrete part = binding + service (how and where). Questions often ask you to “explain the structure of WSDL with an example”.

A complete WSDL example

A temperature-conversion service with one operation, celsiusToFahrenheit (send a Celsius value, get back Fahrenheit). Read the comments – each numbered block is one WSDL element:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="TemperatureService"
    targetNamespace="http://virtuallp.com/temperature"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://virtuallp.com/temperature"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- 1. types: the data structures -->
  <types>
    <xsd:schema targetNamespace="http://virtuallp.com/temperature">
      <xsd:element name="celsiusToFahrenheit">
        <xsd:complexType><xsd:sequence>
          <xsd:element name="celsius" type="xsd:double"/>
        </xsd:sequence></xsd:complexType>
      </xsd:element>
      <xsd:element name="celsiusToFahrenheitResponse">
        <xsd:complexType><xsd:sequence>
          <xsd:element name="return" type="xsd:double"/>
        </xsd:sequence></xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </types>

  <!-- 2. messages: what goes in and out -->
  <message name="CelsiusRequest">
    <part name="parameters" element="tns:celsiusToFahrenheit"/>
  </message>
  <message name="CelsiusResponse">
    <part name="parameters" element="tns:celsiusToFahrenheitResponse"/>
  </message>

  <!-- 3. portType: the abstract interface -->
  <portType name="TemperaturePortType">
    <operation name="celsiusToFahrenheit">
      <input  message="tns:CelsiusRequest"/>
      <output message="tns:CelsiusResponse"/>
    </operation>
  </portType>

  <!-- 4. binding: SOAP over HTTP, document/literal -->
  <binding name="TemperatureBinding" type="tns:TemperaturePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="celsiusToFahrenheit">
      <soap:operation soapAction=""/>
      <input><soap:body use="literal"/></input>
      <output><soap:body use="literal"/></output>
    </operation>
  </binding>

  <!-- 5. service: where it lives -->
  <service name="TemperatureService">
    <port name="TemperaturePort" binding="tns:TemperatureBinding">
      <soap:address location="http://localhost:8080/ws/temperature"/>
    </port>
  </service>
</definitions>

How to read it, step by step:

  1. types – the input is a number called celsius; the output is a number called return.
  2. message – CelsiusRequest carries the input, CelsiusResponse carries the output.
  3. portType – there is one operation, celsiusToFahrenheit, which takes the request and gives the response.
  4. binding – it uses SOAP over HTTP in document/literal style.
  5. service – you call it at http://localhost:8080/ws/temperature.

Message exchange patterns (operation types)

Pattern Elements in <operation> Meaning Everyday example
One-way <input> only Client sends, no reply Dropping a letter in a post box
Request–response <input> then <output> Most common – client waits for a reply Asking a question and waiting for the answer
Solicit–response <output> then <input> The service starts and waits for a reply The bank calls you and asks for a confirmation
Notification <output> only The service sends, no reply expected An SMS alert from your bank

Binding styles

Style / use Description
document/literal The SOAP body holds an XML document checked against the schema. Recommended by the WS-I Basic Profile (a guide for compatibility); the default in JAX-WS (Java API for XML Web Services).
rpc/literal The body wraps the parameters in an element named after the operation (like a function call).
rpc/encoded Adds extra SOAP type information; not WS-I compliant – old and no longer used.

WSDL 1.1 vs WSDL 2.0

WSDL 1.1 WSDL 2.0
definitions root description root
portType interface
port endpoint
Has message elements No message – types are used directly
Widely used (JAX-WS) W3C Recommendation 2007, used less

Producing and consuming a WSDL in Java

With JAX-WS (Java's library for SOAP web services) you rarely write WSDL by hand:

  • Bottom-up (code-first) – you write a Java class with annotations; Java creates the WSDL for you, available at http://host/service?wsdl.
  • Top-down (contract-first) – you start from a WSDL and generate Java code from it with wsimport.

Java 11+ needs a separate JAX-WS tool installation; wsimport is not included in the JDK (Java Development Kit).

# Generate client stubs (ready-made calling code) from a running service's WSDL
wsimport -keep -p com.virtuallp.client http://localhost:8080/ws/temperature?wsdl
In the real world

Banking, insurance and government systems (for example GST and payment switches) still publish WSDL contracts, because WSDL + XML Schema gives strict, checked interfaces. Public clouds such as AWS (Amazon Web Services) EC2 (Elastic Compute Cloud) also offered a SOAP/WSDL interface in the past, next to their REST-style API.

UDDI in brief

UDDI (Universal Description, Discovery and Integration) is a standard for a directory of web services. It holds three kinds of information:

  • White pages – business name and contact details (like a name directory).
  • Yellow pages – the type of business / industry category (like a business directory).
  • Green pages – technical details: links to the WSDL documents (how to call the service).

Public UDDI registries closed in 2006. This syllabus keeps UDDI to explain classic SOA. Service catalogues and API portals are other ways to list and find services.

Summary

  • A web service is a program that other programs can call over a network; it works across languages, describes itself, and uses standard protocols.
  • SOA has three roles – provider, registry, requester – and three actions – publish, find, bind.
  • WSDL describes what (types, message, portType), how (binding) and where (service/port).
  • Operations follow one-way, request-response, solicit-response or notification patterns.
  • JAX-WS creates WSDL from code, or code from WSDL (wsimport).

Practice questions

  1. Define a web service. List its characteristics.
  2. Explain SOA with a neat diagram showing publish, find and bind.
  3. Explain the structure of a WSDL document with an example.
  4. Differentiate between the abstract and concrete parts of WSDL.
  5. What are the four operation types in WSDL?
  6. Compare WSDL 1.1 and WSDL 2.0.
  7. What is UDDI? Explain white, yellow and green pages.

Create a free account to track your progress and unlock virtual labs.