1

我需要开发一个简单的 SOAP 服务,它只允许客户端调用它的方法并获取一个字符串值,我在 PHP ZEND 框架上有以下文件,一旦我转到这个地址 >>> http://localhost/Zend/MyProject /library/client.php 结果是 >> ID:<<< 我正在使用 MAMP ,请帮我整理一下,谢谢

<?php
class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {

        $this->getHelper('viewRenderer')->setNoRender(true);

          // initialize server and set URI
          $server = new Zend_Soap_Server(null, 
            array('uri' => 'http://localhost/Zend/MyProject/public/index'));

          // set SOAP service class
          $server->setClass('Example_Manager');

         $server->setObject(new Example_Manager());

          // handle request
          $server->handle();
          //$request = $server ->getLastRequest();
    }
}

?php
class Example_Manager {

    /**
     * Returns list of all products in database
     *
     * @return array
     */
    public function getProducts($name) 
    {
      return “Product" .$name //should be without semicolon
    }

}
?>


<?php
// load Zend libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Soap_Client');
try {
// initialize SOAP client
$options = array(
  'location' => 'http://localhost/Zend/MyProject/public/index/',
  'uri'      => 'http://localhost/Zend/MyProject/public/index/',
);


  $client = new Zend_Soap_Client(null, $options);  
  $id = $client->getProducts("Here");
  print_r($id);
  echo "ID:" .$id. "<<<";

} catch (SoapFault $s) {
  die('ERROR: [' . $s->faultcode . '] ' . $s->faultstring);
} catch (Exception $e) {
  die('ERROR: ' . $e->getMessage());
}
?>
4

1 回答 1

0

getProducts 方法中存在语法错误,缺少分号。要快速检查您的 sytnax 是否正确,您可以使用 php -l

于 2012-05-10T08:36:08.823 回答