Listening to PHP function calls to intercept the returned value
- by Lansen Q
I am working on making use of a Web Services API offered by the hosts of our internal system. I am accessing it via PHP with the built-in SOAP offering.
The API session is initiated by a remote call to a function that returns some session tokens; every call to any function thereafter will return a new session token, which must accompany the next request.
I have an API Client class that is doing the bulk of the work; what I would like to do is to set something up whereby any SOAP call that is made will make sure to update the API Client class' $session variable with the new session details, and then pass the data along.
So far the only way I can think of doing this is creating a new class extending the SoapClient class, with a __call function wrapper to execute the function, update the new session token, and return the results nonetheless. I'm not sure that this will a) work b) be the best way to go about this. The wrapper class would be identical to making a SOAP call, and it would return an identical result, just it would update the session token before you get your result back.
Thanks! Hope I explained myself properly.