Hey Lev,
Picking back up on this. I've pulled the latest and the instance url stuff is working great.
If you attempt to use an instance of the SalesforceSoapPartner class with an instance of the Salesforce class that has not been authorized or whose access token has timed out, a SOAP fault occurs. In the case of not being authorized, the underlying SOAP client will thrown an INVALID_SOAP_HEADER error (because of missing session id). If the access token has timed out it will throw a INVALID_SESSION_ID error. The underlying toolkit handles neither of these errors gracefully and you'll end up with PHP fatals.
The patch is a simple workaround that makes sure we always have a good session id but first checking if the Salesforce instance is authorized. If it is, it will run an API call which will cause the access token to be refreshed if it has timed out. If the Salesforce instance is not authorized, a log entry is made and a status is set on the instance that can then be checked before running any operations.
I believe a real fix would be to either have the SalesforceSoapPartner be able to refresh it's own session header or somehow keep track of the session expiry so that an API call would only be made if that expiry has passed.
Let me know what you think.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | salesforce-soap-errors-code_standard_dependant-1935612.patch | 3.66 KB | ceardach |
| #3 | salesforce-soap-errors-1935612.patch | 3.27 KB | ceardach |
| #1 | salesforce-soap-errors-1935612-1.patch | 3.27 KB | pcave |
Comments
Comment #1
pcave commentedHere is said patch.
Comment #2
kostajh commentedComment #3
ceardach commentedAttached is a rerolled patch that applies to the current tip of 7.x-3.x-dev.
I've run it through my test suite which includes extensive soap contact and manipulation with Salesforce and everything passed.
Comment #4
kostajh commentedThanks @ceardach
Would you be willing to contribute your tests? It would be useful get a test suite established for the project.
Comment #5
ceardach commentedI will be posting the tests I have specific to the Salesforce module shortly. The rest of the tests, however, are specific to my custom modules.
Attached is a new patch that can be applied after #1951674: Clean up code to match coding standards is applied.
Comment #6
levelos commentedThanks guys, committed. Although I'm wondering what the
SalesforceSoapPartner::isConnected()is for?Comment #7
ceardach commentedIt is so you can check to see if the SalesforceSoapPartner has a valid connection before trying to use it so you don't end up with a fatal error.
Comment #8
levelos commentedBut the only way it will ever be false is if
$this->salesforceApi->isAuthorized()returns false, and we already have that property available. Not a big deal obviously, just want to make sure we really need that additional property.Comment #9
ceardach commented$this->salesforceApi->isAuthorized()will return TRUE even when the session has timed out, and then SalesforceSoapPartner will try to connect and fail throwing a fatal error.Comment #10
levelos commentedI believe with the following snippet,
SalesforceSoapPartner::isConnected()will always be true and redundant.Comment #11
ceardach commentedHmmm.... Going to need to call for pcave for details on this one.
Comment #12
pcave commentedI don't have any issues with a little redundancy. Since I live in the world of the SOAP API I frequently find myself doing things directly with that API without first consulting the Salesforce class. I'm not married to it so if you feel it's not needed go ahead and remove it. I don't think we've actually coded against it anywhere.