Writing SMTP-Based SOAP Messages in PHP
By Shane Caraveo, October 01, 2002
With the buzz around web services, most SOAP usage has focused around the HTTP protocol, but other protocols can be used as well. SMTP has advantages not found with HTTP, including SMTP's ability to store and forward messages, implement one-to-many broadcast messaging, and use attachments to embed extra data into a SOAP message.
October 2002/Writing SMTP-Based SOAP Messages in PHP
Listing 1: The SMTP and HTTP SOAP envelopes
SOAP SMTP envelope:
Date: Tue, 14 May 2002 17:43:13 UT
To: [email protected]
From: [email protected]
Subject: SOAP message
X-Mailer: SOAP::Lite/Perl/0.52
Message-ID: <[email protected]>
Soapaction: "http://soapinterop.org/"
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: quoted/printable
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<namesp1:echoString xmlns:namesp1="http://soapinterop.org/">
<c-gensym3 xsi:type="xsd:string">Hello World</c-gensym3>
</namesp1:echoString>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP HTTP envelope:
POST http://pear.php.net/soap_interop/server_round2.php
Accept: text/xml
Accept: multipart/*
Content-Length: 529
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://soapinterop.org/"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<namesp1:echoString xmlns:namesp1="http://soapinterop.org/">
<c-gensym3 xsi:type="xsd:string">Hello World</c-gensym3>
</namesp1:echoString>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>