Step-by-Step Pack

Web Services WSDL Step by Step Tutorial

Learn to build SOAP web services with PHP and WSDL. This pack covers creating SOAP servers, defining service contracts, and cross-language interop with VB.NET.

Web services and WSDL development with PHP

Why SOAP and WSDL Still Matter

REST dominates modern API design, but SOAP remains heavily used in enterprise systems, payment gateways, and government integrations. If you work with banks, shipping providers, or legacy ERP systems, you will encounter WSDL files.

Understanding how to build and consume SOAP services in PHP gives you a skill that is hard to replace with REST knowledge alone. WSDL provides a strict contract - both sides know exactly what data types and operations are available before a single request is sent.

Pack Overview

This pack takes you through three stages. First, you build a basic SOAP server in PHP using the built-in SoapServer class. Second, you extend that server with a proper WSDL definition. Third, you see how a VB.NET client can consume your PHP SOAP service, proving real cross-language interoperability.

Walkthrough

Step 1 - Create a Basic SOAP Server

The first article sets up a minimal SOAP server. You will write a PHP class whose public methods become the service operations. Then you instantiate SoapServer in non-WSDL mode and point it at your class.

The key file structure is simple:

  • server.php - creates the SoapServer instance
  • functions.php - holds the class with your service methods

Non-WSDL mode is useful for quick testing but it does not give clients a formal contract. Clients must know the method names and parameter types in advance.

Step 2 - Add a WSDL Definition

The second article introduces the WSDL file. WSDL is XML that describes your service: what operations exist, what parameters they accept, and what they return. PHP’s SoapServer can read this file and enforce the types automatically.

Writing WSDL by hand is tedious. The XML is verbose and a single misplaced tag breaks everything. Start by copying a working example and modifying the types and operation names to match your class.

Common trouble spots:

  • The targetNamespace in the WSDL must match what you pass to SoapServer
  • The location attribute must point to the actual URL of your server script
  • Complex types need <xsd:sequence> elements even if they only have one field

Step 3 - Cross-Language Consumption

The third article demonstrates a VB.NET client calling your PHP SOAP service. This is where the value of WSDL becomes obvious. Visual Studio reads the WSDL file, generates proxy classes, and you can call PHP functions as if they were local .NET methods.

This pattern works the other way too. PHP’s SoapClient class can consume any WSDL endpoint, regardless of what language the server uses.

Debugging SOAP Services

SOAP errors are notoriously hard to debug. Here are some techniques that save time:

Enable PHP error reporting. Set display_errors = On and error_reporting = E_ALL during development. SOAP faults often mask the real PHP error underneath.

Log raw XML. Use SoapServer::fault() and SoapClient::__getLastRequest() / __getLastResponse() to capture the actual XML being exchanged.

Test with SoapUI. Load your WSDL into SoapUI and it will generate sample requests automatically. This isolates server problems from client problems quickly.

Common Pitfalls

SOAP extension not loaded. Check phpinfo() for the SOAP section. On many systems you need to uncomment extension=soap in php.ini.

Namespace mismatches. The namespace in your WSDL, your server code, and your client code must all agree. A single character difference causes cryptic “function not found” errors.

Caching stale WSDL. PHP caches WSDL files by default. During development, set soap.wsdl_cache_enabled = 0 in php.ini or you will go crazy wondering why changes do not take effect.

FAQ

Is SOAP still worth learning in 2026?
Yes, for specific use cases. Enterprise integrations, financial services, and many government APIs still require SOAP. Knowing it makes you more versatile.

Can I generate WSDL automatically from my PHP class?
There is no built-in PHP tool for this, but libraries exist. You can also write the WSDL once and maintain it manually - it rarely changes once the API is stable.

What is the difference between document/literal and RPC/encoded?
Document/literal sends XML documents directly. RPC/encoded wraps parameters in a method-call structure. Document/literal is the modern standard and has better interoperability.

How do I handle authentication in SOAP?
Use WS-Security headers or pass credentials in a custom SOAP header. Basic HTTP authentication also works if the transport is HTTPS.

Can I use SOAP over HTTPS?
Yes. Configure your web server with SSL and update the WSDL location to use https://. PHP’s SOAP client handles HTTPS natively.

Articles in This Pack

  1. 1 Web Services WSDL - Creating SOAP Server (Part 1)
  2. 2 Web Services WSDL - Creating SOAP Server (Part 2)
  3. 3 Web Services - How PHP Kiss VB.NET Part 1

Pack Checklist

  • PHP 5.x or later with the SOAP extension enabled
  • A web server (Apache or Nginx) running locally
  • Basic understanding of XML structure
  • Optional: Visual Studio for VB.NET client testing
  • A tool like SoapUI or curl for testing SOAP requests