Exploring Web Services and XML — SOAP, WSDL, and UDDI

Alexander Obregon
3 min readApr 23, 2023

--

Image Source

Introduction

Web services are a powerful technology that enables different applications to communicate and exchange data over the internet. They rely on standardized protocols like SOAP, WSDL, and UDDI to create interoperable applications. In this article, we will take a look at each of these components and their importance in the world of web services. We will also have some code examples to help understand their implementation.

SOAP (Simple Object Access Protocol)

SOAP is an XML-based messaging protocol that allows applications to exchange structured information over the internet. It provides a standard way for applications to communicate with each other, regardless of the programming language or platform they use.

Example: SOAP Request and Response

SOAP requests and responses are structured as XML documents. Here’s an example of a simple SOAP request to a “HelloWorld” web service:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://example.com/">
<name>John Doe</name>
</HelloWorld>
</soap:Body>
</soap:Envelope>

And the corresponding SOAP response:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://example.com/">
<HelloWorldResult>Hello, John Doe!</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>

WSDL (Web Services Description Language)

WSDL is an XML-based language used to describe web services and their operations, inputs, and outputs. It provides a way for developers to understand how to interact with a web service without having to access its source code.

Example: WSDL Document

A WSDL document includes the following components:

  • Definitions: Define the data types, messages, and operations.
  • Types: Define the data types used in the messages.
  • Messages: Define the structure of the data exchanged.
  • Port Type: Define the operations and their input/output messages.
  • Binding: Specify the protocol and encoding style for the operations.
  • Service: Define the network address and binding information.

Here’s a simple example of a WSDL document for the “HelloWorld” web service:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.com/" targetNamespace="http://example.com/">
<types>
<xsd:schema targetNamespace="http://example.com/">
<xsd:element name="HelloWorld">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="HelloWorldResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="HelloWorldResult" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="HelloWorldRequest">
<part name="parameters" element="tns:HelloWorld"/>
</message>
<message name="HelloWorldResponse">
<part name="parameters" element="tns:HelloWorldResponse"/>
</message>
<portType name="HelloWorldServicePortType">
<operation name="HelloWorld">
<input message="tns:HelloWorldRequest"/>
<output message="tns:HelloWorldResponse"/>
</operation>
</portType>
<binding name="HelloWorldServiceBinding" type="tns:HelloWorldServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="HelloWorld">
<soap:operation soapAction="http://example.com/HelloWorld"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloWorldService">
<port name="HelloWorldServicePort" binding="tns:HelloWorldServiceBinding">
<soap:address location="http://example.com/HelloWorldService.asmx"/>
</port>
</service>
</definitions>

UDDI (Universal Description, Discovery, and Integration)

UDDI is a registry standard for web services, allowing businesses to publish and discover services over the internet. It provides a centralized directory where developers can search for and obtain information about available web services.

Example: UDDI Inquiry API

An example of using the UDDI Inquiry API to find a web service with a specific service key:

<?xml version="1.0" encoding="UTF-8"?>
<find_service xmlns="urn:uddi-org:api_v2" serviceKey="uddi:example.com:service_helloWorld">
</find_service>

The response may include information about the web service, such as its binding templates, which provide details on how to access the service:

<?xml version="1.0" encoding="UTF-8"?>
<serviceList xmlns="urn:uddi-org:api_v2">
<serviceInfos>
<serviceInfo serviceKey="uddi:example.com:service_helloWorld">
<name xml:lang="en">HelloWorldService</name>
<bindingTemplates>
<bindingTemplate bindingKey="uddi:example.com:binding_helloWorld">
<accessPoint URLType="http">http://example.com/HelloWorldService.asmx</accessPoint>
</bindingTemplate>
</bindingTemplates>
</serviceInfo>
</serviceInfos>
</serviceList>

Conclusion

SOAP, WSDL, and UDDI are fundamental components of web services, providing a standardized approach for applications to communicate and exchange data. SOAP enables the messaging between applications, WSDL describes the web services and their operations, and UDDI facilitates the discovery and integration of services. By understanding and implementing these technologies, developers can create interoperable and scalable applications that harness the power of the internet.

  1. SOAP Tutorial with Examples
  2. WSDL Tutorial with Examples
  3. UDDI Tutorial with Examples

--

--

Alexander Obregon

Software Engineer, fervent coder & writer. Devoted to learning & assisting others. Connect on LinkedIn: https://www.linkedin.com/in/alexander-obregon-97849b229/