2

I am integrating PHP with salesforce using SOAP, and use xampp server. It gives me error Class 'SoapClient' not found . after i remove ; before the extension=php_soap.dll and extension=php_openssl.dll and restart the server. then i try to execute PHP script it gives me error apache HTTP server has stop working. code is

define("USERNAME", "   USERNAME  ");
define("PASSWORD", " PASSWORD  ");
define("SECURITY_TOKEN", "SECURITY_TOKEN ");


    require_once ('soapclient/SforcePartnerClient.php');
    $mySforceConnection = new SforcePartnerClient();
    $mySforceConnection->createConnection("PartnerWSDL.xml");
    $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
    $query = "SELECT Id, Name,Company ,LeadSource, Status from Lead"; //querying data from object


    $response = $mySforceConnection->query($query); //sending request and getting response using SOAP
    foreach ($response->records as $record) //iterating through the response and displaying data
    {   echo '<tr>
        <td>'.$record->Id.'</td>
        <td>'.$record->fields->Name.'</td>
        <td>'.$record->fields->Company.'</td>
        <td>'.$record->fields->LeadSource.'</td>
        <td>'.$record->fields->Status.'</td>

         </tr>'; }?>
</table>


        ?>

3 Answers 3

2

Explanation:

The issue is that the SforceSoapClient that is instantiated like so:

require_once ('soapclient/SforcePartnerClient.php');
# Create a new Salesforce Partner object
$sfConnector = new SforcePartnerClient();
# Create the SOAP connection to Salesforce
try {
    $sfConnector->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {
    /* Salesforce could be down, or you have an error in configuration, 
       Check your WSDL path Otherwise, handle this exception */
    print( 'Connection Error: '.$e );
}

Because the SforceSoapClient extends SoapClient within that file, you are getting the following:

Fatal error: Class 'SoapClient' not found

SoapClient is an extension of PHP that must be enabled in order to be extended here. I'm using WAMP, you mentioned you're using XAMPP, either way they both have a PHP directory with a php.ini file as you mentioned. It is possible within XAMPP you're editing the wrong php.ini

Solution:

Make sure you are editing the correct configuration file. Besides xampp\php\php.ini also look for xampp\apache2\bin\php.ini

Also, if after editing the file if you get an error restarting your server than there is likely an issue within the file. You can check the logs to see what may be causing it to fail.

Hope that helps you or someone else ;)

0

You don't need those php dll. the problem is your code is unable to find soapclinet directory. Make sure soapclient folder exist besides the file you are executing.

require_once ('soapclient/SforcePartnerClient.php');
1
  • I have this included which is what causes the issue because the client extends SoapClass which doesn't exist in the toolkit repository. (i.e. class SforceSoapClient extends SoapClient). I've searched everywhere, there is no SoapClient class to be found Commented Sep 13, 2016 at 18:01
0

php-soap might be missing in the server

If you do have root access, and you're not running cpanel/whm You can try one of the following commands:

sudo yum install php-soap
sudo aptitude install php-soap
sudo pear install php-soap

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .