问题
I'm trying to access a web service that requires a call to 2 methods, one for login and an other one for the real results.
After doing tests in SoapUI I could get the results after checking "maintain HTTP session'. So I made a login request, then the result request and it worked.
How can I handle "SOAP sessions" in PHP?
回答1:
Looking at php's SoapClient class does not look like that it has code to automatically handle sessions persistence.
Instead you could do something like getting the cookies from the SoapClient manually using
$SoapClient->_cookies
after logging in, store it in some place (file, database, memcache, etc), and set that cookie before doing any query on subsequent (separate) calls using __setCookie
You could try to extend the SoapClient class and "decorate" it with the cookie-persistence code, because at some point the cookie might expire and your method calls will fail. You can do something to re-authenticate in that case and update your cookie data with a new one.
来源:https://stackoverflow.com/questions/13732307/how-to-maintain-sessions-in-soapclient-php