在您发表评论后,我决定重写我的答案并使用 wsdl 为您提供一些解决方案:
<?php
require_once('Zend/Soap/Client.php');
require_once('Zend/Soap/Server.php');
require_once('Zend/Soap/Wsdl.php');
require_once('Zend/Soap/AutoDiscover.php');
class SoapController extends AppController
{
public function zendclientAction()
{
$_client = new Zend_Soap_Client('http://localhost/php5_testapp/soap/zendserver?wsdl');
$_ret = $_client->addNumbers(3, 5);
echo('<pre>');
var_dump($_ret);
echo('<pre>');
die();
}
public function zendserverAction()
{
if(isset($_GET['wsdl'])) {
$_autod = new Zend_Soap_AutoDiscover();
$_autod->setClass('MySoapServerClass');
$_autod->handle();
}
else {
$_server = new Zend_Soap_Server('http://localhost/php5_testapp/soap/zendserver?wsdl');
$_server->setClass("MySoapServerClass");
$_server->handle();
}
exit;
}
}
/**
* My Soap Server Class
*/
class MySoapServerClass {
/**
* This method adds two numbers
*
* @param integer $a
* @param integer $b
* @return string
*/
public function addNumbers($a, $b) {
return 'Outcome is: ' . ($a + $b);
}
}
现在你可以添加任何你想要的类!但请记住 - 您的课程应该有很好的文档记录,因为 WSDL 文件是基于此生成的。
希望能帮助到你!