views:

102

answers:

0

I've created a WSDL-based SOAP web service using PHP 5.3. I'm using Zend Framework to handle the service, and ZF in turn is layered atop PHP's built-in SoapServer class.

In testing with SoapUI, I discovered that passing a parameter of invalid type (e.g., passing a string when an integer is defined by the WSDL) resulted an empty response. Digging into the code, I discovered that when ZF calls SoapServer->handle(), execution dies with this fatal error:

Fatal error: SOAP-ERROR: Encoding: Violation of encoding rules

The error makes sense, but for the life of me, I cannot figure out how to capture it so that I may gracefully handle it. My understanding is that handle() should throw an exception, but it's instead simply dying.

But here's where it gets really weird....

Running multiple tests with SoapUI, without making any code changes, produces different results. Most of the time, I get the empty response, but occasionally, I get back a SoapFault (what I'd expect!). It's not consistent, however, and I cannot figure out what triggers it either way. As far as I can tell, I have the caching features in SoapUI turned off, as well as WSDL caching. I don't know if it's something with SoapUI or PHP. As I said, weird.

Related, I found this old PHP bug:

http://bugs.php.net/36629

that sounds an awful like my own problem. I'm not completely convinced, though, that that's my issue, mostly because the PHP documentation covering all this, as well as the docs for ZF, are woefully incomplete. Thus, I may very well simply be doing something terribly wrong and not know it. In light of that, I'd love to see a simple shell that shows the proper way to trap and handle errors. But I'll take any help that folks out there may be able to offer.