views:

453

answers:

1

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.

class WsController extends AppController{

var $uses = array();

function info()  {
    $this->layout= null;
    $ns="http://www.techvoicellc.com/Tutorials//"; 
 $server = new soap_server(); 


 $server->configureWSDL('mostafa',$ns); 
 $server->wsdl->schemaTargetNamespace=$ns; 
 $server->wsdl->addComplexType('ArrayOfstring','complexType', 
    'array','','SOAP-ENC:Array',array()
    ,array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]')), 
    'xsd:string'); 


  $server->register('sum', 
    array('x' => 'xsd:integer','y' => 'xsd:integer'),        
    array('z' => 'xsd:integer'),   
    $ns,                                           
    "$ns#sum",                               
    'rpc',                                        
    'encoded',                                    
    'documentation'     // documentation 
    );  

    $server->service($HTTP_RAW_POST_DATA); 
}

 function sum($x,$y){ 
 $z=$x+$y;
 return new soapval('return','xsd:integer',$z);
 } 

}

and i create the clint in controller action like this

function index() {
   $wsdl = 'http://localhost/asd/ws/info?wsdl';
   $client = new nusoap_client ( $wsdl, true );

   $this->client = new nusoap_client($wsdl, true);
   $param1 = array ('x' => 2, 'y' => 1 );
   $a = $client->call ( 'sum', $param1 );
    echo $a;
 }

it don't do any thins although that i create this in non cake project and its work very well

hope some one tell me what is the best practise to create web-service in cake php

A: 

Here are the possible answers to your question:

http://rossoft.wordpress.com/2006/02/17/web-services-in-cakephp-complex-types/ http://bakery.cakephp.org/articles/view/restful-web-services-with-cakephp

Sarfraz
i alredy check this links ithink the problem that the code can't register the sum function, every thing is ok but he can't catch the action sum in the controller, because of the nature of mvc frame work and there is another post about web service in this bloghttp://rossoft.wordpress.com/ that containe some modification nusoap files but the all broken down .
islam