开发者

SoapServer persistence fails randomly

I've made SOAP WSDL service which works. I've added 2 methods to test - the first one (setX($x)) sets $this->x to $x, second one (getX()) returns $this->x. The constructor of my SOAP class sets $this->x to 'FAIL', while client code calls setX('SUCCESS').

I've added some dummy variables to make them both request-response type (one-way seem to have some weird problems with some clients).

Well, it works, client calls $s->setX('SUCCESS') and $x = $s->getX(''), and $x = 'SUCCESS'. As expected.

But to achieve this, I had to use following option with client:

'cache_wsdl' => WSDL_CACHE_MEMORY

Why? It beats me. With every other option it just doesn't work - $x = 'FAIL' (no persistence)

OK, it works, so what's the problem? Sometimes, YES, SOMETIMES it doesn't work. The code randomly returns 'FAIL' (as persistence was broken). When it start to return 'FAIL' it keeps to do so. You can start another browser, and it will MOST PROBABLY report 'SUCCESS'.

Now the weirdest part. Let's use one browser. Let's repeat following steps: start the browser, check the code output until it returns 'FAIL'. Now, press 'Ctrl+R' for about 2 seconds. Suddenly it works, now it's 'SUCCESS' every time!

WTF?!!! I really double checked the session. Session is created properly before each time SoapServer is created. Each time $server->setPersistence(SOAP_PERSISTENCE_SESSION) is called. And it works only "most of the time" - which makes it completely useless!

Any clues?

PS: My service WSDL is generated and cached. I've added sleep(1) to WSDL generator, and benchmarked client code. It seems not to regenerate WSDL (ends in ca. 10ms - not 1010ms). Invalidating WSDL cache (with TTL set to 1) doesn't make persistence work, but stupid holding Ctrl+R in browser does!

PS2: WSDL generator, SOAP class and test client are in 3 different files. WSDL class actually starts the server. It's called from the file which contains SOAP class (index.php).

PS3: I removed .htaccess which shou开发者_如何学Cld not break anything, I removed some unused files and code, and boom - now it works everytime, with any type of wsdl_cache! Well, I don't know what it was, .htaccess? Maybe Apache server internal problems. I cannot reproduce it anymore. If you experience similar problems, my advice is to drop .htaccess and try to restart Apache. The problems happened very early morning / late night - I'm not sure but I think cron does some intensive backup tasks at the time. Maybe compulsive reloading told Linux to relax with background tasks and put more resources to Apache and PHP - this would explain weird Ctrl+R behavior.

UPDATE: It still fails randomly! Works most of the time, but I can't rely on this feature. (Tested with different service, different client, but still the same server).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜