How to maintain sessions in SoapClient - PHP

隐身守侯 提交于 2020-01-07 04:42:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!