function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
J. J. MarkJ. J. Mark 

SOAP PHP API - Could not connect to host

Using API Version 33.0. Simple code below results with "Cound not connect to host".

I am reasonably certain this has to do with recent PHP/OpenSSL security fixes, but not sure how to fix it with the Salesforce API. We've fixed this issue in other integrations (e.g. Marketo) by enhancing the SoapClient instantiation with "$options = array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true));" but with the Salesforce API we do not have direct access to the options for the Soap Client instantiation.

Help?

TIA

==============================================

 
require_once ('salesforce2/SforcePartnerClient.php');
require_once ('salesforce2/SforceHeaderOptions.php');

try {
$mySforceConnection = new SforcePartnerClient();    
$mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml');

$location=$mySforceConnection->getLocation();
$mySforceConnection->setEndpoint($location);
$mylogin = $mySforceConnection->login('user', 'password');

} catch (Exception $e) {    
 echo $mySforceConnection->getLastRequest();    
 echo $e->faultstring;    
}

 
Himanshu ParasharHimanshu Parashar
Hi Mark,

This should certainly work. Are you in developer edition ?
J. J. MarkJ. J. Mark
Trying to connect to our production instance. Also tried a full sandbox
J. J. MarkJ. J. Mark
I got it to function by including a new $options parameter to the createConnection method


 
$options = array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true));
$context = stream_context_create($options);
$options = array('stream_context'=>$context);


$mySforceConnection = new SforcePartnerClient();	
$mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml','',$options);