我正在创建一个 Web 服务,我添加了一个接收对象但我的肥皂客户端无法识别其属性的操作
<?php
class Application_Model_Contact {
private $id;
private $name;
private $phone;
/**
*
* @param String $nome
* @param String $phone
*/
public function __construct($nome = null, $phone = null) {
....
}
}
...
class Application_Model_WebServices
{
/**
*
* @param Application_Model_Contact $contact
* @return boolean
*/
public function adicionar(Application_Model_Contact $contact){
return true;
}
}
……
if (isset($_GET['wsdl'])) {
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('Application_Model_WebServices');
$autodiscover->handle();
} else {
$server = new Zend_Soap_Server();
$server->setOptions(array(
'soap_version' => SOAP_1_2,
'actor' => 'http://localhost/AgendaTelefonicaPHPSOAP/public/webservice.php',
'encoding' => 'UTF-8'
));
$server->setWsdl('http://localhost/AgendaTelefonicaPHPSOAP/public/webservice.php?wsdl');
$server->setClass('Application_Model_WebServices');
$server->handle();
}
使用soapUI,我得到以下xml来添加这个对象
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://localhost/AgendaTelefonicaPHPSOAP/public/webservice.php">
<soapenv:Header/>
<soapenv:Body>
<web:adicionar soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<contact xsi:type="web:Application_Model_Contact"/>
</web:adicionar>
</soapenv:Body>
</soapenv:Envelope>
为什么我的类属性没有被识别?