PHP Error Class 'SoapClient' not found

InfiniteGeoff picture InfiniteGeoff · Jul 19, 2012 · Viewed 14.4k times · Source

I was trying to install Wordpress on our server to test, but in order to do that I had to upgrade our current PHP version to 5.3. I upgraded our PHP and I am now finding that our Purolator shipping module is no longer working. According to our host support the "purolator.php" file is missing data that the new version of PHP requires. Unfortunately, I can't revert our PHP version back and our programmer is away.

This is the error message I was able to get from our website host support team:

tail /var/www/vhosts/phantomcables.com/statistics/logs/error_log -f 
[Thu Jul 19 08:34:28 2012] [error] [client 70.51.168.201] PHP Fatal 
error:  Class 'SoapClient' not found in 
/var/www/vhosts/phantomcables.com/httpdocs/shippings/purolator.php on line 
49, referer: https://phantomcables.com/index.php?dispatch=checkout.cart 

These are lines 40 to 72:

function createPWSSOAPClient()
{
    /** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and 
    *           header information
    **/
    //Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials
    //echo DIR_SHIPPING_FILES."estimatingservice.wsdl";

    $url = "https://webservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx";
    $client = new SoapClient( DIR_SHIPPING_FILES."estimatingservice.wsdl", 
                              array (
                                        'trace'         =>  true,
                                        'location'      =>  $url,
                                        'uri'           =>  "http://purolator.com/pws/datatypes/v1",
                                        'login'         =>  PRODUCTION_KEY,
                                        'password'      =>  PRODUCTION_PASS
                                    )
                            );

    //Define the SOAP Envelope Headers
    $headers[] = new SoapHeader ( 'http://purolator.com/pws/datatypes/v1', 'RequestContext', 
                                  array (
                                            'Version'           =>  '1.0',
                                            'Language'          =>  'en',
                                            'GroupID'           =>  'xxx',
                                            'RequestReference'  =>  'Rating Example'
                                       )
                                ); 
    //Apply the SOAP Header to your client                            
    $client->__setSoapHeaders($headers);

    return $client;
}

Any help would be greatly appreciated.

Answer

Romain picture Romain · Jul 19, 2012

It seems like you did not have installed the php-soap package on your server. Type

phpinfo();

in your code and check if 'Soap Client' is 'enabled'. If not, I don't know your distribution and package manager, but here is the code for Fedora I use:

$ yum install php-soap

I suggest to do it with your programmer back or a sys admin by your sides, you never know what could happen. A backup is also useful before any installation!