Zend soap appel à la méthode avec trait d'union
-
28-10-2019 - |
Question
Je réécris le fichier client soap en utilisant le framework Zend.
C'est une ancienne méthode.ça fonctionne.
function getBassaService(){
global $service;
$h="127.0.0.1";
$p="8000";
if($service==null){
$service = new SoapClient("/test/php/bassa.wsdl", array(
"soap_version" => SOAP_1_2,
"trace" => 1,
"exceptions" => 1,
"location" => "http://".$h.":".$p));
}
return $service;
}
function getAllDownloads(){
global $service;
$client = getService();
try{
$results = $client->__soapCall("list-all", array());
}catch(SoapFault $e){
print($e->faultstring);
}
return $result;
}
Voici mon nouveau code.J'utilise Zend_Soap_Client.
const HOST = "127.0.0.1";
const PORT = "8095";
protected $_client;
public function __construct()
{
$this->_client = new Zend_Soap_Client(APPLICATION_PATH ."/services/bassa.wsdl",
array(
"soap_version" => SOAP_1_2,
"uri" => "http://". self::HOST .":". self::PORT
)
);
}
public function getAllDownloads()
{
$result = $this->_client->list-all();
return $result;
}
Mon serveur soap a la méthode list-all
.Je veux faire appel à cette méthode.Mais l'erreur suivante s'est produite.Parce que le nom de la méthode a un trait d'union.
Notice: Undefined property: Zend_Soap_Client::$list in /home/dinuka/workspace/testzend/application/services/SoapClient.php on line 57
Fatal error: Call to undefined function all() in /home/dinuka/workspace/testzend/application/services/SoapClient.php on line 57
Comment je l'ai résolu.Aidez-moi, s'il vous plaît.
La solution
étrange.cela devrait fonctionner.cela pourrait être un bogue dans le framework ZF.il essaie peut-être de convertir le nom de la fonction en un nom de fonction de cas de chameau avec des variables.
Essayez d'utiliser la fonction magique directement en appelant:
$this->_client->__call('list-all', array('param1' => $param1))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow