title: cakephp webservice
body: <p>I have problem in creating web-service using cakephp .
  this what i do to create this web-service .
  I use NuSOAP - Web Services Toolkit for PHP for this.
  I create a controller called WsController  and import the library on it.</p>
  
  <pre><code>class WsController extends AppController{
  
  var $uses = array();
  
  function info()  {
      $this-&gt;layout= null;
      $ns="http://www.techvoicellc.com/Tutorials//"; 
      $server = new soap_server(); 
  
  
      $server-&gt;configureWSDL('mostafa',$ns); 
      $server-&gt;wsdl-&gt;schemaTargetNamespace=$ns; 
      $server-&gt;wsdl-&gt;addComplexType('ArrayOfstring','complexType', 
      'array','','SOAP-ENC:Array',array()
      ,array(array('ref'=&gt;'SOAP-ENC:arrayType','wsdl:arrayType'=&gt;'string[]')), 
      'xsd:string'); 
  
  
      $server-&gt;register('sum', 
      array('x' =&gt; 'xsd:integer','y' =&gt; 'xsd:integer'),        
      array('z' =&gt; 'xsd:integer'),   
      $ns,                                           
      "$ns#sum",                               
      'rpc',                                        
      'encoded',                                    
      'documentation'     // documentation 
      );  
  
      $server-&gt;service($HTTP_RAW_POST_DATA); 
  }
  
   function sum($x,$y){ 
      $z=$x+$y;
      return new soapval('return','xsd:integer',$z);
   } 
  
  }
  </code></pre>
  
  <p>and i create the clint in controller action like this </p>
  
  <pre><code>function index() {
     $wsdl = 'http://localhost/asd/ws/info?wsdl';
     $client = new nusoap_client ( $wsdl, true );
  
     $this-&gt;client = new nusoap_client($wsdl, true);
     $param1 = array ('x' =&gt; 2, 'y' =&gt; 1 );
     $a = $client-&gt;call ( 'sum', $param1 );
      echo $a;
   }
  </code></pre>
  
  <p>it don't do any thins although that i create this in non cake project and its work very well </p>
  
  <p>hope some one tell me what is the best practise to create web-service in cake php</p>