Bug #47584 [Com]: WSDL error in soapClient causes Fatal Error

[email protected] ("joelpenner at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=47584&edit=1

 ID:                 47584
 Comment by:         joelpenner at gmail dot com
 Reported by:        gem at rellim dot com
 Summary:            WSDL error in soapClient causes Fatal Error
 Status:             Not a bug
 Type:               Bug
 Package:            SOAP related
 Operating System:   Linux
 PHP Version:        5.2.9
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Situation 1: WSDL does not exist but soap server is giving an html response (some sort of server error).

Unexpected behavior: PHP 7 crash without being caught, PHP 5.6 crash without being caught.

Expected behavior: Catchable soap exception

Situation 2: Valid WSDL but PHP 7 crash without being caught, PHP 5.6 crash without being caught.

Work around for PHP 7: URL for WSDL needs an extra slash between the SERVER_NAME and the REQUEST_URI. For example http://www.server.com/abc/wsdl becomes http://www.server.com//abc/wsdl

Work around for PHP 5.6: ini_set("soap.wsdl_cache_enabled", "0");

Seeing as in earlier PHP versions I get memory errors, I wonder if this is related to the fact that the Synergize WSDL I'm using is massive.


Previous Comments:
------------------------------------------------------------------------
[2015-12-22 16:53:33] jpenn at tmwsystems dot com

This is a bug in PHP 7.0.0 VC14 X64 with Apache 2.4.17 (Win64) VC14

I am NOT running Xdebug.
Occurs on Windows 7 Professional (my development environment).

class MaddSoapClient extends SoapClient
{
  public function __construct($wsdl, $options = null) {
    // Created some code to make sure the wsdl is valid
    $isValid = true;
    if($isValid) {
      try {
        if($options != null) @parent::SoapClient($wsdl, $options);
        else @parent::SoapClient($wsdl);
      } catch(SoapFault $sf) {
        // log SF
      } catch(Exception $e) {
        // log Exception
      }
    }
  }
}

$msc = new MaddSoapClient("http://qasynergize.tmwsystems.com/SynWebService/Explorer.asmx?wsdl", array("exceptions" => true, 'connection_timeout' => 0, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));

The above error handler hacks don't work.
Email me for any settings information you like.

PHP 5.6.16 VC11 X64 throws an out of memory error but still works with the above code. PHP 5.4.45 works regardless.

------------------------------------------------------------------------
[2014-06-03 11:12:24] stefan at mailinator dot com

This is an issue with Xdebug, we also had this in PHP 5.3.10

http://bugs.xdebug.org/view.php?id=249

------------------------------------------------------------------------
[2012-10-03 09:36:52] james dot silver at computerminds dot co dot uk

The above solution(s) worked for me on an Ubuntu server, but not on IIS. My final solution added in a 
custom error handler which did the trick - e.g:

<?php
if (function_exists('xdebug_disable')) {
  xdebug_disable();
}
set_error_handler('my_custom_soap_wsdl_error_handler');
new SoapClient('http://google.com', array('exceptions' => TRUE));
restore_error_handler();
if (function_exists('xdebug_enable')) {
  xdebug_enable();
}

function my_custom_soap_wsdl_error_handler($errno, $errstr, $errfile = NULL, $errline = NULL, 
$errcontext = NULL) {
  // Simulate the exception that Soap *should* have thrown instead of an error.
  // This is needed to support certain IIS server setups it would seem.
  $wsdl_url = isset($errcontext['wsdl']) ? $errcontext['wsdl'] : '';
  $msg = "SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl_url . "' : failed to load external 
entity \"" . $wsdl_url . "\"";
  if (class_exists('SoapFault')) {
    $e = new SoapFault('WSDL', $msg);
  }
  else {
    $e = new Exception($msg, 0);
  }
  throw $e;
}
?>

------------------------------------------------------------------------
[2012-01-26 08:40:50] zpon dot dk at gmail dot com

I had to surround my SoapClient call with xdebug_disable(); and xdebug_enable(); 
(@ was not enough) to work around this problem.

------------------------------------------------------------------------
[2010-09-02 21:10:09] gem at rellim dot com

I was a confirmed bug in earlier versions.  So it should be 'Fixed' not "Bogus'.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=47584


--
Edit this bug report at https://bugs.php.net/bug.php?id=47584&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.