2

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
mr. w
  • 2,348
  • 1
  • 21
  • 26
  • Is this reported bug related? http://bugs.php.net/bug.php?id=49513 – MrWhite Jul 16 '10 at 19:04
  • I do believe so. In fact, it looks like all of these are related: http://bugs.php.net/bug.php?id=36629 http://bugs.php.net/bug.php?id=50547 http://bugs.php.net/bug.php?id=50895 http://bugs.php.net/bug.php?id=50547 http://bugs.php.net/bug.php?id=49513 – mr. w Aug 25 '10 at 16:42

2 Answers2

1

Could you try comment: https://bugs.php.net/bug.php?id=50547#1298563236 (third comment on the page)?

Xdebug might be the problem. When using xdebug_disable() before calling the handle() method, the server responds with a proper SOAP message which says that something went wrong.

I had the exact same problem (sometimes an empty response, sometimes a correct SoapFault). xdebug_disable() saved me.

j0k
  • 22,600
  • 28
  • 79
  • 90
0

If you send a bad XML, Zend Framework send a SoapFault Exception :

// Zend/Soap/Server.php line 818
try {
    $this->_setRequest($request);
} catch (Zend_Soap_Server_Exception $e) {
    $setRequestException = $e;
}

With this code, only Exception was transformed to SoapFault. But all PHP Error don't throw Exception and SoapServer not display error :

// Zend/Soap/Server.php line 857
protected function _initializeSoapErrorContext()
{
    $displayErrorsOriginalState = ini_get('display_errors');
    // Delete this line to view error in developement
    ini_set('display_errors', false);

    set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR);
    return $displayErrorsOriginalState;
}

I don't know how return SoapFault all time. Sorry. I am searching ... ;)