doushi1510 2012-05-10 08:17
浏览 29

没有结果,网络服务

I need to develop a simple SOAP service which just allow client to invoke its method and get a string value, I have the followings files on PHP ZEND Framework, once I go to this address >>> http://localhost/Zend/MyProject/library/client.php the result is >> ID:<<< I am using MAMP , please help me to sort it out , thanks

<?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());
}
?>
  • 写回答

1条回答 默认 最新

  • doushi1929 2012-05-10 08:36
    关注

    There's a syntax error in the getProducts method, a semicolon ist missing. To check quickly if your sytnax is correct, you can use php -l

    评论

报告相同问题?

悬赏问题

  • ¥20 Keil编译时报错"no source": Error: #5: cannot open source
  • ¥50 操作系统时间无法更新
  • ¥20 Windows11, usb转hdmi,外接显示器无反应
  • ¥20 怎么在JavaFx的TableView中动态地添加数据。
  • ¥15 MFC里的工具栏按钮图标使用外部图片
  • ¥15 如何在 llama.cpp 服务器中实现用户登录功能的优化方案?(语言-c++)
  • ¥15 有会用octave 的吗,急!代做!好偿!
  • ¥15 有一套同城小程序源码,Uniapp前端,php+html+mysql后端 ,能不能教我搭建起来可以运行,我不知道怎样操作
  • ¥15 mac调用java.io接口无法在根目录生成文件
  • ¥15 java微服务节点假死,网关路由时长延迟