In the soapclient.php script, it should not be a Zend_Exception. It should be
a regular Exception:
Change:
--------------
soapclient.php
--------------
<?php
/**
* Base path
*/
define('BASE_PATH', realpath(dirname('../../')));
/**
* Application path
*/
define('APPLICATION_PATH', BASE_PATH . '/application');
/**
* Library path
*/
define('LIBRARY_PATH', BASE_PATH . '/library');
// Set the include path
set_include_path(LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
/**
* @see Zend_Debug
*/
require_once 'Zend/Debug.php';
require_once "Zend/Exception.php";
require_once "Zend/Soap/Client.php";
try {
$client = new Zend_Soap_Client("http://localhost/soap/server/?wsdl");
$string = $client->helloWorld();
$server = $client->getServer();
Zend_Debug::dump($string, eval('return __FILE__;') . ' $string', true);
Zend_Debug::dump($server, eval('return __FILE__;') . ' $server', true);
} catch(Exception $e) {
echo $e->getMessage();
}
?>
gammamatrix wrote:
>
> Here is a way to accomplish the task. This is a simple hello world
> example.
>
> --------------
> Soap/HelloWorld.php
> --------------
>
> <?php
> class Soap_HelloWorld
> {
> /**
> * Return hello world
> * @return string
> */
> public function helloWorld()
> {
> return 'Hello world';
> }
>
> /**
> * Return $_SERVER array
> * @return array
> */
> public function getServer()
> {
> return $_SERVER;
> }
> }
>
> --------------
> soapclient.php
> --------------
>
> <?php
> /**
> * Base path
> */
> define('BASE_PATH', realpath(dirname('../../')));
>
> /**
> * Application path
> */
> define('APPLICATION_PATH', BASE_PATH . '/application');
>
> /**
> * Library path
> */
> define('LIBRARY_PATH', BASE_PATH . '/library');
>
> // Set the include path
> set_include_path(LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
>
> /**
> * @see Zend_Debug
> */
> require_once 'Zend/Debug.php';
>
> require_once "Zend/Exception.php";
> require_once "Zend/Soap/Client.php";
>
> try {
>
> $client = new Zend_Soap_Client("http://localhost/soap/server/?wsdl");
> $string = $client->helloWorld();
> $server = $client->getServer();
>
> Zend_Debug::dump($string, eval('return __FILE__;') . ' $string',
> true);
> Zend_Debug::dump($server, eval('return __FILE__;') . ' $server',
> true);
> } catch(Zend_Exception $e) {
> echo $e->getMessage();
> }
> ?>
>
> --------------
> ServerController.php
> --------------
>
> class Soap_ServerController extends Zend_Controller_Action
> {
> /**
> * indexAction
> *
> * Index Action
> */
> public function indexAction()
> {
> $this->_helper->viewRenderer->setNoRender();
> $this->_helper->layout()->disableLayout();
>
> require_once 'Soap/HelloWorld.php';
> ob_end_clean();
>
> if(isset($_GET['wsdl'])) {
> $autodiscover = new Zend_Soap_AutoDiscover();
> $autodiscover->setClass('Soap_HelloWorld');
>
> ob_start();
> $autodiscover->handle();
> ob_end_flush();
> }
> else {
> $soap = new
> Zend_Soap_Server("http://localhost/soap/server/?wsdl");
> $soap->setClass('Soap_HelloWorld');
> $soap->handle();
> }
> }
> }
> --------------
>
> In this example you need to use the output buffering functions otherwise
> you may end up with a corrupted wsdl file.
>
> Before running the script, go to the URL:
>
> http://localhost/soap/server/?wsdl
>
> Or wherever you put the action. You should see the wsdl xml file. put the
> soapclient.php file in the web root for testing:
>
> http://localhost/soapclient.php
>
> You should see the variable dumps in the browser.
>
> MVC information:
>
> module: soap
> controller: server
> action: index
>
> Please note:
> - You need to disable layouts and rendering.
> - You may need to delete cached wsdl files from the server tmp directory.
> By default they live for 24 hours.
>
> Maybe at some point we can put this example in the documentation.
>
> - Jeremy Postlethwaite
>
--
View this message in context:
http://www.nabble.com/Building-a-MVC-based-Soap-server-tp18980591p24849477.html
Sent from the Zend Framework mailing list archive at Nabble.com.