时间:2021-07-01 10:21:17 帮助过:23人阅读
class WebServiceController extends Zend_Controller_Action {
public function init() {
$this->_helper->viewRenderer->setNoRender();
}
public function indexAction() {
if (isset($_GET['wsdl'])) {
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('Service_Helloworld');
$autodiscover->handle();
} else {
$soap = new Zend_Soap_Server("http://zf-demo.localhost/WebService/index/?wsdl");
$soap->setClass('Service_Helloworld');
$soap->handle();
}
}
public function testAction() {
$params = array(
'name' => 'tom'
);
$client = new SoapClient("http://zf-demo.localhost/WebService/index/?wsdl", array('trace' => 1));
echo $client->__soapCall('sayHello', $params);
}
}
class Service_Helloworld {
/**
* say hello
* @param string $name
* @return string
*/
public function sayHello($name) {
return 'hello ' . $name;
}
}