jump to navigation

Webservices in CakePHP [other approach] February 16, 2006

Posted by rossoft in CakePHP.

I was thinking other approach for webservices for having the code more clean and easier.

1. Copy this little hacked version of nusoap to /vendors/nusoap/nusoap.php
2. Copy this controller class to /vendors/nusoap/web_services_controller.php
3. Copy this component (nusoap client) to /app/controllers/components/soap.php

Developing a server

The services will be in the url http://myhost/customer_services/
(open that url in your browser for see the info of the webservice)

1. The controller

class CustomerServicesController extends WebServicesController
var $name=’CustomerServices’;
var $uses=array(‘Customer’);
var $api=array(
‘add’=>array (    ‘doc’=>’create a customer’,
‘name’=>array(‘doc’=>’gets the name of a customer’,
function add($code,$name)
$data[‘Customer’][‘id’] = $code;
$data[‘Customer’][‘name’] = $name;

function name($code)
return $data[0][‘Customer’][‘name’];
That’s all!

Developing a client

class TestController extends AppController
var $components=array(’aaa’,’bbb’,’soap’);

function test()
$this->set(’name’,$name); //for the view



1. rossoft - February 16, 2006

Q: what you had to modify in nusoap?
A: In nusoap you can call a global function or a method of a class. If you call a method of a class, then it will create a new instance of that class and calls the method on that instance. Also, he changes the name of the method of the service to something like ‘CustomerServiceController.add’. It didn’t worked for me, the new instance of the controller didn’t had the model variables set. I changed it passing the $this variable to the register method

2. Sebastian Fahrenkrog - November 17, 2006


I’m very thankfull for this modifications. That’s exactly what I was searching for. I install everything but noticed one litte error:
If browser the Soap Service and click on WDSL the wrong page ist displayed. The Soap Code used PHP_SELF.


3. felix - February 1, 2007

please rossft can you see how you’ve passed $this tothe register method?

4. rossoft - February 1, 2007

@felix: see the hacked nusoap version, the link is at the top of this article. I don’t remember the changes…

5. Robert - March 15, 2007

When using this method the page gets redirected to /webroot/index.php instead of the controller, thus generating an error.
I think it’s because of the PHP_SELF used, but i have no idea how to fix it.

My current fix gives a version mismatch:

web_services_controller.php (line 74 – 76)

$fap = “http://dev.edore.nl/”.$this->params[‘url’][‘url’];
$this->_soap_server->configureWSDL($wsdl, $urn, $fap);

6. Robert - March 16, 2007

In reply to the previous post, i’ve fixed it.

Correct line: (line 75-76)

$url= FULL_BASE_URL.’/’.$this->params[‘url’][‘url’];
$this->_soap_server->configureWSDL($wsdl, $urn, $url);

Also a note: do not use /customer_services/wsdl (wich does work) because the path isn’t correct then. Always use /customer_services?wsdl

7. dz - June 9, 2007

hello, is it possible to return an array with this, like from $this->Model->findAll()?

thanks, regards

8. bobby - June 13, 2007

How I see the request and respond of SOAP working?


9. Ian - July 9, 2007

The linking to the files does not seem to be working. Is that a problem or is it just me?

10. ChameleonBR - July 15, 2007

This files not exist, nusoap.php.txt, web_services_controller.php.txt and soap.php.txt.
Someone can place in bakery please.


11. Hafeez Hameed - September 11, 2007

All the following installation files are not present here
1. Copy this little hacked version of nusoap to /vendors/nusoap/nusoap.php
2. Copy this controller class to /vendors/nusoap/web_services_controller.php
3. Copy this component (nusoap client)

i need to implement a web service in cake, therefore if anyone has all these files plz send them to me… i’ll be very thankful to you.
my email is: hafeez2cool@yahoo.com

12. rajkumar - November 6, 2007

i implemented webservices but i got error anybody send me sample files in zip plz help me

send me at : rajkumar.sakti@gmail.com

with regards

13. Ismael - January 5, 2008

Hi everybody,
For those who need them, Here are some mirrors of the files that are used in this post, because the links were not working.

Hola a todos,
Para aquellos que los necesiten, aqui estan los archivos usados en este post, ya que los links no funcionaban:

file/archivo: webservices.zip


14. john - January 14, 2008

1. Copy this little hacked version of nusoap to /vendors/nusoap/nusoap.php
2. Copy this controller class to /vendors/nusoap/web_services_controller.php
3. Copy this component (nusoap client) to /app/controllers/components/soap.php

where i can get those files mentioned on the installation guide?

15. Pangui - February 28, 2008

Thanks to Ross and Franck

I’ve implemented successfully this tutorial of phpcake+nusoap. The code is available for download at

thanks again!


Gracias a Ross y Franck

Implementé con éxito este tutorial de phpcake y nusoap. El código que utilice está disponible para descarga en

gracias otra vez!


16. Mr-Yellow - April 17, 2008

The client component is missing from the zip posted.

Can’t find any other info on CakePHP with SOAP client apart from people using PHP5. Anyone have this file?

17. geoge - July 28, 2011
18. Rpllqlfr - September 3, 2011

Please call back later little nymphet cp 8DDD

19. Nyqinhod - September 5, 2011

How many weeks’ holiday a year are there? young nude actress %-]]

20. Opyjssri - September 5, 2011

Could you tell me the number for ? forever model preteen :-]]

21. Jrwivmpm - September 6, 2011

Go travelling free young teen lesbians oeqa

22. Iznvswwl - September 6, 2011

Where’s the postbox? sexy underage upskirt plkoi

23. Laotnxju - September 7, 2011

I’m sorry, I didn’t catch your name pedo stars

24. Hvzbhhpw - September 8, 2011

Have you read any good books lately? early girl toplist

25. Egvzxoqw - September 24, 2011

A pension scheme Loli Dorki Pthc

26. Lcgbrpac - September 25, 2011

Wonderfull great site Kasandra Model

27. Blytxfzl - May 3, 2012

How many would you like? http://efylehooryy.de.tl strawberry nude model The way her ass is coming down on his dick toward the end of the vid is very sexy ^_^

28. lokesh - June 17, 2014

Please provide the files again, as i unable to download it

lokesh - June 17, 2014

Forgot to mention my email id lokesh_java@rediffmail.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: