Creating a simple SOAP server

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.

How to do it...

  1. 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 the prospects table:
    namespace Application\Web\Soap;
    use PDO;
    class ProspectsApi
    {
      protected $registerKeys;
      protected $pdo;
            
      public function __construct($pdo, $registeredKeys)
      {
        $this->pdo = $pdo;
        $this->registeredKeys = $registeredKeys;
      }
    }
  2. We then define ...

Get PHP 7 Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.