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
}

http://php.net/manual/en/function.extension-loaded.php

Answer:

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

var_dump(class_exists("SOAPClient"));

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

Answer:

From SSH you can run:

php -i | grep Soap

that will return something like:

Soap Client => enabled
Soap Server => enabled

Answer:

in the command line type the following:

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

Answer:

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

<?php
    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");
        die();
    }
?>

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.
extension=php_soap.dll
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 : http://windows.php.net/download#php-5.6 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 :

<php
    echo phpinfo();
?>

Answer:

in a php file :

<?php
echo phpinfo();
?>

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

Answer:

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

Answer:

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

http://[your-domain.com]/phpinfo.php

Leave a Reply

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