简体   繁体   中英

How can I check whether the server is able to handle SOAP requests

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.

You can use:

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

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

From SSH you can run:

php -i | grep Soap

that will return something like:

Soap Client => enabled
Soap Server => enabled

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.

在命令行中键入以下内容:

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

in a php file :

<?php
echo phpinfo();
?>

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

EDIT : be careful with other solutions using php CLI (Command Line Interface), because you don't have the same php.ini used for the CLI and for your web server (for example apache). Thus it may differ.

Then if you use apache and you want to see if soap is enabled, it's better to indicate the apache php.ini file in the command line, for instance :

php -c /etc/php/apache2/php.ini -i | grep Soap

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();
?>

PEAR 包没有在 phpinfo() 中列出,所以如果“soap”没有出现在你的“test.php”页面上,这是正常的!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM