Monday, October 6, 2008

How To Make NuSOAP Work With PHP 5

NuSOAP is a very usefull SOAP Toolkit for developing web service with PHP. You won't have any problem when using it with PHP 4. But, if you are using PHP 5, you might find a little problem. PHP 5 has its own SOAP extension, so if that SOAP extension is loaded it will conflict with NuSOAP and you will get an error message like this:

Fatal error: Cannot redeclare class soapclient in C:\xampp\htdocs\lib\nusoap.php on line 7240

There are two alternatives to solve this problem.

First Alternative

You can de-activated PHP SOAP extension by editting the php.ini file. Give a semicolon (;)  in the front of the line says extension=php_soap.dll. So, that line should be look like this:

;extension=php_soap.dll

Restart your web server to make the change take effect.


Second Alternative

You can also modify the nusoap.php file to rename the soapclient class to another name like soap_client.  You can use your favorite text editor and replace all soapclient text with soap_client. So, if you want to make an instance from NuSOAP client you have to use the syntax like this:

$client=new soap_client($url);

This way is good if you want to use NuSOAP but you still want to retain the PHP SOAP extension.


3 comments:

Anonymous said...

The error messages are from the SOAP support built into PHP 5. When
using PHP 5, be sure you have NuSOAP 0.7.3 and use the nusoap_client and
nusoap_server classes instead of soapclient and soap_server.

refer http://osdir.com/ml/php.nusoap.general/2007-11/msg00067.html

---
ph++

Karthick Balaraman said...

WOW!!!! That saved my time.. thanks a ton....

Yudistyra said...

Thanks a lot.. I'd have frustated if I can't solved this problem..
thank you very much.. ^^