php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47584 WSDL error in soapClient causes Fatal Error
Submitted: 2009-03-06 07:42 UTC Modified: 2010-09-02 21:10 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: gem at rellim dot com Assigned: dmitry (profile)
Status: Not a bug Package: SOAP related
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gem at rellim dot com
New email:
PHP Version: OS:

 

 [2009-03-06 07:42 UTC] gem at rellim dot com
Description:
------------
Basically bug# 34657 says it all, except the bug is not bogus.

I am NOT running Xdebug and any problem reading the remote WSDL
causes a fatal error which makes it impossible to inform the
user nicely of the problem.

Reproduce code:
---------------
$client = new SoapClient('http://google.com');


Expected result:
----------------
I would like to see a catchable error or an error return;

Actual result:
--------------
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://google.com' 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-06 15:32 UTC] iliaa@php.net
It already works that way.
 [2009-03-06 17:49 UTC] gem at rellim dot com
Why does it work OK for you and not for me?  Just because it
works on one host for you does not mean it does not fail for me.

This is the entire program to reproduce:
<?php
$client = new soapClient('http://google.com');
?>

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: XXXX

I can reproduce on several different hosts.  I am not
running Xdebug, eaccelerator, or any other add in.
 [2010-04-09 07:41 UTC] pwb at evanr dot com
This is a real issue, even when the SoapClient is set to throw exceptions and not 
errors.  This fatal error cannot be defeated even with the exceptions option set 
to true.

We're experiencing this in 5.2.13 on linux x64.

A fatal error is thrown not only when WSDL can't be loaded but as well when an 
internal reference in the WSDL (e.g. to a namespace) cannot be imported/resolved.
 [2010-06-22 10:35 UTC] florent dot biville at insa-rouen dot fr
I can confirm I encounter the same problem.
Despite everything documented, problems with WSDL reading will trigger a fatal error.
 [2010-06-24 01:55 UTC] gem at rellim dot com
This is a still a 100% show  stopper for me.  I can not make PHP pages live
that will crash on simple network errors.
 [2010-08-31 07:52 UTC] fa@php.net
-Status: Bogus +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2010-09-02 10:40 UTC] dmitry@php.net
-Status: Assigned +Status: Feedback
 [2010-09-02 10:40 UTC] dmitry@php.net
BTW despite SoapClient emits a fatal error it already throws exception which can be caught (even in 5.2 brunch).

<?php
try {
  $x = new SoapClient("non-existent.wsdl");
} catch (Exception $e) {
}
echo "ok\n";'
?>
 [2010-09-02 19:14 UTC] gem at rellim dot com
Your example fails for me, I can not catch the error:

# cat tmp.php
<?php  
try {  
    $x = new SoapClient("non-existent.wsdl");  
} catch (Exception $e) {  
}  
echo "ok\n";
?> 
 


# php tmp.php
PHP Warning:  SoapClient::SoapClient(): I/O warning : failed to load external 
entity "non-existent.wsdl" in /tmp/tmp.php on line 3
PHP Stack trace:
PHP   1. {main}() /tmp/tmp.php:0
PHP   2. SoapClient->SoapClient() /tmp/tmp.php:3
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'non-
existent.wsdl' : failed to load external entity "non-existent.wsdl"
 in /tmp/tmp.php on line 3
PHP Stack trace:
PHP   1. {main}() /tmp/tmp.php:0
PHP   2. SoapClient->SoapClient() /tmp/tmp.php:3
#
 [2010-09-02 19:15 UTC] gem at rellim dot com
Forgot my version details:

# php -v
PHP 5.3.3 (cli) (built: Jul 26 2010 14:55:07) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by 
eAccelerator
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
 [2010-09-02 19:17 UTC] gem at rellim dot com
It fails similarly without XDebug:

# php -v
PHP 5.3.3 (cli) (built: Jul 26 2010 14:55:07) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by 
eAccelerator

# php tmp.php
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'non-
existent.wsdl' : failed to load external entity "non-existent.wsdl"
 in /tmp/tmp.php on line 3
ok
 
#
 [2010-09-02 19:20 UTC] gem at rellim dot com
Hmm, on 2nd look, it does now appear catchable w/o XDebug, but not with XDebug.  

Ideas?
 [2010-09-02 19:22 UTC] rasmus@php.net
It is a catchable fatal though.

eg.

<?php  
try {  
    $x = @new SoapClient("non-existent.wsdl",array("exceptions" => 1));  
} catch (SoapFault $E) {  
    echo $E->faultstring; 
}  
echo "ok\n";
 [2010-09-02 19:33 UTC] gem at rellim dot com
Not catchable for me with XDebug and your example:


# cat tmp.php
<?php  
try {  
    $x = @new SoapClient("non-existent.wsdl",array("exceptions" => 1));  
} catch (SoapFault $E) {  
    echo $E->faultstring; 
}  
echo "ok\n";

?>

# php tmp.php
#
 [2010-09-02 19:34 UTC] gem at rellim dot com
I do see it catchable now without XDebug.

# php tmp.php
SOAP-ERROR: Parsing WSDL: Couldn't load from 'non-existent.wsdl' : failed to load 
external entity "non-existent.wsdl"
ok

#
 [2010-09-02 19:37 UTC] rasmus@php.net
-Status: Feedback +Status: Bogus
 [2010-09-02 19:37 UTC] rasmus@php.net
Right, so this is not a PHP bug.  Perhaps a feature request to downgrade that 
particular error to a Warning instead of a catchable fatal, but that is all I see.
 [2010-09-02 21:10 UTC] gem at rellim dot com
I was a confirmed bug in earlier versions.  So it should be 'Fixed' not "Bogus'.
 [2012-01-26 08:40 UTC] 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.
 [2012-10-03 09:36 UTC] 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;
}
?>
 [2014-06-03 11:12 UTC] 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
 [2015-12-22 16:53 UTC] 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.
 [2015-12-23 18:36 UTC] joelpenner at gmail dot com
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 04:01:28 2024 UTC