PHP 5.3.10 SoapServer::handle 找不到函数
PHP 5.3.10 SoapServer::handle not finding function
我在 Apache2 错误日志中收到此错误:
PHP Fatal error: Function 'ns1:getClients' doesn't exist
我查看了为什么 PHP Soap 服务器没有在 class Client_API
中找到方法并且在 index.php
文件中看不到任何课程:
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();
包含缺失方法的Class:
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;
}
//...
任何帮助将不胜感激,我一直在想它是否与 PHP 版本不匹配有关,它在 5.3.3 版本上工作,但在 5.3.10 版本上不工作。所以只有细微差别。
我已经能够通过将 uri
选项设置为 'uri'=>'api'
来解决这个问题。似乎将其留空不是一个好主意。它仍然让我感到困惑,它如何在 Windows 上的相同版本的 PHP 上正常工作。
这 post 让我得到了答案:Issues with SOAP in non-WSDL mode。
我在 Apache2 错误日志中收到此错误:
PHP Fatal error: Function 'ns1:getClients' doesn't exist
我查看了为什么 PHP Soap 服务器没有在 class Client_API
中找到方法并且在 index.php
文件中看不到任何课程:
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();
包含缺失方法的Class:
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;
}
//...
任何帮助将不胜感激,我一直在想它是否与 PHP 版本不匹配有关,它在 5.3.3 版本上工作,但在 5.3.10 版本上不工作。所以只有细微差别。
我已经能够通过将 uri
选项设置为 'uri'=>'api'
来解决这个问题。似乎将其留空不是一个好主意。它仍然让我感到困惑,它如何在 Windows 上的相同版本的 PHP 上正常工作。
这 post 让我得到了答案:Issues with SOAP in non-WSDL mode。