php – How can I check whether the server is able to handle SOAP requests-ThrowExceptions

Exception or error:

How can I check whether the server is able to handle SOAP requests at run time ?
I need to verify it before my script is executing.

How to solve:

You can use:

if (extension_loaded('soap')) {
  // Do things


In PHP to check whether SOAP enabled or not use built in function class_exists():


It also could be user to check any of modules classes.


From SSH you can run:

php -i | grep Soap

that will return something like:

Soap Client => enabled
Soap Server => enabled


in the command line type the following:

>>  php -r 'echo (extension_loaded("soap")?"LOADED\n":"not loaded\n");'


Hmm… I’m new and I’m bad :
I tried this in a “test.php” file.

    if (extension_loaded('soap')) 
        echo phpinfo();
    else //will redirect to sth else so you know it doesn't work
        header("Location: http://localhost/index.html");

And I saw myself looking at a “phpinfo()” page with a paragraph called : “soap”.

Sorry for the misinterpretation.

To install SOAP :
Check your “php.ini” file, look for “extension”.
You should find a line :
extension=php_soap.dll or ;extension=php_soap.dll
“;” means it’s commented.
Uncomment it.
If you didn’t find the line, then put it there.
Make sure the dll file actually is in the default folder php/ext.
If it isn’t, check on phpinfo() is your version is VC6, VC9 of VC11, go to the php download page : and get the correspondant version of php zip file.
Steal their “php_soap.dll” from their /ext folder and put it in yours.
You’re all set!
Restart your servers, then go to your phpinfo() test page to check if it works.

Good luck.
Note :
phpinfo() simple test.php file :

    echo phpinfo();


in a php file :

echo phpinfo();

and then look for SOAP and you will see if SOAP is installed and enabled


PEAR packages are not listed in phpinfo(), so if “soap” doesn’t appear on your “test.php” page, it’s normal !


You can use the phpinfo script to see is SOAP is installed.


Leave a Reply

Your email address will not be published. Required fields are marked *