Advertisement
dragonbe

Zend_Soap server/client

Mar 7th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. <?php
  2. // file: application/models/UpperLower.php
  3. class Application_Model_UpperLower
  4. {
  5.     /**
  6.      * Converts a string to all upper strings
  7.      *
  8.      * @param   string $string
  9.      * @return  string
  10.      */
  11.     public function convertUpper($string)
  12.     {
  13.         return strtoupper($string);
  14.     }
  15.     /**
  16.      * Converts a string to all lower strings
  17.      *
  18.      * @param   string $string
  19.      * @return  string
  20.      */
  21.     public function convertLower($string)
  22.     {
  23.         return strtolower($string);
  24.     }
  25. }
  26.  
  27.  
  28.  
  29. <?php
  30. // file: application/controllers/SoapController.php
  31. class SoapController extends Zend_Controller_Action
  32. {
  33.  
  34.     public function init()
  35.     {
  36.        
  37.     }
  38.  
  39.     public function indexAction()
  40.     {
  41.       $this->_helper->viewRenderer->setNoRender(true);
  42.       if(isset($_GET['wsdl'])) {
  43.           $autodiscover = new Zend_Soap_AutoDiscover();
  44.           $autodiscover->setClass('Application_Model_UpperLower');
  45.           $autodiscover->handle();
  46.       } else {
  47.           // pointing to the current file here
  48.           $soap = new Zend_Soap_Server("http://zftraining.osx/soap/index?wsdl");
  49.           $soap->setClass('Application_Model_UpperLower');
  50.           $soap->handle();
  51.       }
  52.     }
  53.     public function convertAction()
  54.     {
  55.         $string = $this->getRequest()->getParam('string', 'AbcXyz');
  56.         $client = new Zend_Soap_Client('http://zftraining.osx/soap/index?wsdl');
  57.         $this->view->string = $string;
  58.         $this->view->upper = $client->convertUpper($string);
  59.         $this->view->lower = $client->convertLower($string);
  60.     }
  61.  
  62.  
  63. }
  64.  
  65. <?php // file: application/views/scripts/soap/convert.phtml ?>
  66. <dl>
  67.  <dt>String: <?php echo $this->escape($this->string) ?></dt>
  68.  <dd>Upper: <?php echo $this->escape($this->upper) ?></dd>
  69.  <dd>Lower: <?php echo $this->escape($this->lower) ?></dd>
  70. </dl>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement