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

Failed Login Function PHP SOAP

We are experiencing an issue where sometimes we cannot log into SalesForce using the following code. It seems to work about 90-95% of the time, but every now and then it fails, and causes a 404 page – the error shown is “Could not connect to host.”. The username and password we’re using (i.e. $this->SF_username) are both valid as it works most of the time.

The issue seems to lie in the “$this->sforce->login” part of the following code, which I believe is handled on the SalesForce end. I can’t find any (code) declaration of that login() function in the “sforce” SoapClient object, though it is present in the “partner.wsdl.xml” XML file. I’ve tried assigning the result of “$this->sforce->login()” to a variable and printing it, but when the login() function fails, it doesn’t get that far, it just triggers the 404 page.

$mySforceConnection = $joomlaSf->getSFConnection();


function getSFConnection()
if ($mySforceConnection->createConnection(JPATH_BASE . '/custom_files/SF_sync/soapclient/partner.wsdl.xml')) {
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->login($this->SF_username, $this->SF_password);

public function login($username, $password) {
if ($this->callOptions != NULL) {
if ($this->loginScopeHeader != NULL) {

// The following function seems to be causing the issue.
$result = $this->sforce->login(array (
'username' => $username,
'password' => $password

$result = $result->result;
return $result;

Does anyone have any insight as to why this happens, and possible solutions to fix this?

Please check if Salesforce is expecting digital certificate to connect with SAlesforce allong with credentials. 
We include the security token in the password if that's what you mean? The strange thing is that it works the majority of the time.