SOAP Web Services Introduction
SOAP (Simple Object Access Protocol) is a messaging protocol for exchanging structured information in web services. In this course, you’ll learn to create and consume SOAP services using PHP.What is SOAP?
SOAP is an XML-based protocol that allows programs running on different operating systems to communicate with each other. It defines:- Message format: XML structure for requests and responses
- Communication protocol: Typically HTTP/HTTPS
- Service description: WSDL (Web Services Description Language)
SOAP is platform-independent and language-independent, making it ideal for enterprise integrations.
SOAP vs REST
| Feature | SOAP | REST |
|---|---|---|
| Protocol | Strict protocol with rules | Architectural style |
| Format | XML only | JSON, XML, others |
| Transport | HTTP, SMTP, TCP | Primarily HTTP |
| State | Can be stateful or stateless | Stateless |
| Complexity | More complex | Simpler |
| Security | WS-Security standard | HTTPS, OAuth |
SOAP Message Structure
A SOAP message is an XML document with three main parts:Message Components
Envelope
The root element that identifies the XML document as a SOAP message. Required in every SOAP message.
Header (Optional)
Contains application-specific information like authentication credentials, transaction IDs, or routing data.
Body (Required)
Contains the actual message intended for the recipient - either a request or a response.
SOAP Request Example
When calling a SOAP service, your request might look like:SOAP Response Example
The server responds with:SOAP Fault Structure
When errors occur, SOAP uses a standardized fault structure:PHP SOAP Extension
PHP provides built-in SOAP support through theSoapClient and SoapServer classes:
When to Use SOAP
SOAP is ideal for:- Enterprise applications with strict contracts
- Financial services requiring high security (WS-Security)
- Legacy system integration where SOAP is already established
- Complex operations requiring stateful interactions
- Formal service contracts with WSDL documentation
Course Context
In TEMA-06, you’ll work with:- Creating SOAP servers with PHP classes
- Generating WSDL files using
php2wsdl - Building SOAP clients to consume services
- Handling complex data types and arrays
- Error handling and debugging SOAP messages
Next Steps
Now that you understand SOAP basics, proceed to:WSDL Generation
Learn to generate WSDL from PHP classes
Consuming Services
Build SOAP clients to call web services
Additional Resources
SOAP Specifications
SOAP Specifications
- SOAP 1.1: https://www.w3.org/TR/2000/NOTE-SOAP-20000508/
- SOAP 1.2: https://www.w3.org/TR/soap12/
PHP SOAP Documentation
PHP SOAP Documentation
- SoapServer: https://www.php.net/manual/en/class.soapserver.php
- SoapClient: https://www.php.net/manual/en/class.soapclient.php
WSDL Specification
WSDL Specification
- WSDL 1.1: https://www.w3.org/TR/wsdl
- WSDL 2.0: https://www.w3.org/TR/wsdl20/