Search code examples
phpsoaplamp

PHP 5.3.10 SoapServer::handle not finding function


I am getting this error in Apache2 errors logs:

PHP Fatal error: Function 'ns1:getClients' doesn't exist

I checked to see why the PHP Soap Server is not locating the method in the class Client_API and can't see any course here's the index.php file:

require(INCLUDES_DIR.'BaseService.class.php');
require($interfaceFile);
require($serviceFile); // loads  /var/www/official-productionapi/includes/Client.service.php
//...
$server = new SoapServer(null, array ('uri'=>'', 'trace' => 1,  'connection_timeout' => intval(600)));
$server->setClass($serviceName.CLASS_SUFFIX); // -- e.g. 'Client_API'
$server->handle();

The Class containing the missing method:

class Client_API extends BaseService implements Client_API_Interface
{   
    public function getClients($range = 10, $search, $accessUserID = null)
    {
        if(!$this->Authenticated){
            throw new SoapFault('Server', 'Authorization failed: Wrong username or password');
        }
        $max = 100;
        $range = (int)$range;
        if($range > $max){
            $range = $max;
        }
        $clients = array();
        $db = Database::getInstance();
        if(null !== $accessUserID){
            $sql = "SELECT * FROM clients as c, users_clients_access as uac WHERE c.ClientID = uac.ClientID AND uac.UserID = '".$db->escape($accessUserID)."' AND c.IsShopAssistClient = 0 AND (c.ClientName LIKE '".$db->escape($search)."%' OR c.Tag LIKE '".$db->escape($search)."%') ORDER BY c.ClientName Asc LIMIT $range";

        }else{
            $sql = "SELECT * FROM clients  WHERE IsShopAssistClient = 0 AND (ClientName LIKE '".$db->escape($search)."%' OR Tag LIKE '".$db->escape($search)."%') ORDER BY ClientName Asc LIMIT $range";
        }
        $clientQ = $db->query($sql);
        while($client = $db->fetch_array($clientQ)){
            $arr = array();
            $arr['PClientName'] = $client['ClientName'];
            $arr['PClientTag'] = $client['Tag'];
            $clients[$client['ClientID']] = $arr;
        }
        return $clients;
    }
//...

Any help would be appreciated, I have been thinking if it has something to do with PHP version mismatch, it was working on version 5.3.3 but it's not on version 5.3.10. So only minor differences.


Solution

  • I have been able to solve this issue by setting uri option to 'uri'=>'api'. Seems like leaving it blank wasn't a good idea. It still boggles me how it works on the same version of PHP on Windows just fine.

    This post led me to my answwer: Issues with SOAP in non-WSDL mode.