
// .htaccess


RewriteEngine On

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php


// StockController


<?php
class StockController extends CController
{
  public function actions()
  {
    return array(
      'quote'=>array(
        'class'=>'CWebServiceAction',
      ),
    );
  }

  /**
   * @param string the symbol of the stock
   * @return float the stock price
   * @soap
   */
  public function getPrice($symbol)
  {
    $prices=array('IBM'=>100, 'GOOGLE'=>350);
    return isset($prices[$symbol])?$prices[$symbol]:0;
  }
}



// client.php


<?php

$client=new SoapClient('http://localhost/test-app/stock/quote');
echo $client->getPrice('GOOGLE');

?>
