As with the SOAP client, we can use the PHP SOAP extension to implement a SOAP server. The most difficult part of the implementation will be generating the WSDL from the API class. We do not cover that process here as there are a number of good WSDL generators available.
First, you need an API that will be handled by the SOAP server. For this example, we define an
Application\Web\Soap\ProspectsApi
class that allows us to create, read, update, and delete theprospects
table:namespace Application\Web\Soap; use PDO; class ProspectsApi { protected $registerKeys; protected $pdo; public function __construct($pdo, $registeredKeys) { $this->pdo = $pdo; $this->registeredKeys = $registeredKeys; } }
We then define methods that correspond to create, read, update, and delete. In this example, the methods are named
put()
,get()
,post()
, anddelete()
. These, in turn, call methods that generate SQL requests that are executed from...